Java Programming - Flow Control - Discussion
Discussion Forum : Flow Control - Finding the output (Q.No. 21)
21.
What will be the output of the program?
int I = 0;
label:
if (I < 2) {
System.out.print("I is " + I);
I++;
continue label;
}
Answer: Option
Explanation:
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.
Discussion:
15 comments Page 2 of 2.
Ranjeet said:
1 decade ago
What is label: here. Please clearly explain?
Ashis said:
1 decade ago
What is label: specified in the program?
Paparao said:
8 years ago
What is a label? What is its function?
(1)
Dipika said:
9 years ago
@Ruba.
The Output is:
5
0
The Output is:
5
0
Uday said:
8 years ago
@Ramu.
The answer is 212.
The answer is 212.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers