Flow Control

Q1: What will be the output of the program?
int I = 0;
label:
    if (I < 2) {
    System.out.print('I is ' + I);
    I++;
    continue label;
}

A I is 0 I is 1

B
 
Compilation fails.

C I is 0

D None of the above

ANS:A - I is 0

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.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.