What is the exact output of the following program Show your
What is the exact output of the following program? Show your import Java. util. *; public class Numbers {public static void main {String [] args} {int i = 1; while (i ![What is the exact output of the following program? Show your import Java. util. *; public class Numbers {public static void main {String [] args} {int i = 1; w What is the exact output of the following program? Show your import Java. util. *; public class Numbers {public static void main {String [] args} {int i = 1; w](/WebImages/11/what-is-the-exact-output-of-the-following-program-show-your-1006973-1761519208-0.webp)
Solution
Program :
import java.util.*;
public class Numbers
{
public static void main(String[] args)
{
int i=1;
while(i<5)
{
myMethod(2+i,i);
i=+1;
}
}
public static void myMethod(int A, int num)
{
for( int k=1; k<=A;k++)
{
System.out.println(num + \" \");
num=num+1;
}
System.out.println();
}
}
Output :The above proigram gives infinite loop
1
2
3
1
2
3
1
2
3
1
2
3
.
.
.
.
.
.
and so on
![What is the exact output of the following program? Show your import Java. util. *; public class Numbers {public static void main {String [] args} {int i = 1; w What is the exact output of the following program? Show your import Java. util. *; public class Numbers {public static void main {String [] args} {int i = 1; w](/WebImages/11/what-is-the-exact-output-of-the-following-program-show-your-1006973-1761519208-0.webp)
![What is the exact output of the following program? Show your import Java. util. *; public class Numbers {public static void main {String [] args} {int i = 1; w What is the exact output of the following program? Show your import Java. util. *; public class Numbers {public static void main {String [] args} {int i = 1; w](/WebImages/11/what-is-the-exact-output-of-the-following-program-show-your-1006973-1761519208-1.webp)