मराठी

Answer the following in brief. Give a reason/example wherever applicable. Give a program example of a method call in a loop.

Advertisements
Advertisements

प्रश्न

Answer the following in brief. Give a reason/example wherever applicable.

Give a program example of a method call in a loop.

कारण सांगा
Advertisements

उत्तर

Example of a method call in a loop:

class Example 
{
    static void display()         
        {
        System.out.println("Hello Java");
    }

    public static void main(String[]args) 
        {
        for(int i=1; i<=5; i++) 
        {
            display();//Method call inside loop
        }
    }
}

Reason: The method display() is called repeatedly inside the for loop, so the same method executes multiple times with each iteration.

shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 3: User-Defined Methods - Exercises [पृष्ठ ९१]

APPEARS IN

रूपा पंडित Computer Applications [English] Class 10 ICSE
पाठ 3 User-Defined Methods
Exercises | Q 5. (vi) | पृष्ठ ९१
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×