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
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
