Sail E0 Webinar
Question


What will be the output of the program?


int I = 0;
label:
if (I < 2) {
System.out.print("I is " + I);
I++;
continue label;
}
Options:
A .  I is 0
B .  I is 0 I is 1
C .  Compilation fails.
D .  None of the above
Answer: Option C

The code will not compile because a continue statement can only occur in a looping 

construct. If this syntax were legal, the combination of the continue and the if statements 

would create a kludgey kind of loop, but the compiler will force you to write cleaner code 

than this.



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers