A

Admin • 828.03K Points
Coach

Q. What is the output of the below Java program with WHILE, BREAK and CONTINUE?

Code:
int cnt=0;
while(true)
{
if(cnt > 4)
break;
if(cnt==0)
{
cnt++;
continue;
}
System.out.print(cnt + ",");
cnt++;
}
  • (A) 0,1,2,3,4,
  • (B) 1,2,3,4,
  • (C) 1,2,3,4
  • (D) Compiler error
  • Correct Answer - Option(B)
  • Views: 11
  • Filed under category Java
  • Hashtags:

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.