हिंदी

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×