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 1 of 2.
Ramu said:
1 decade ago
where can i implement the loop in above program give example
Ramu said:
1 decade ago
I would like to know the next number of the following series
1, 2, 6, 30, 60, 130, ?
1, 2, 6, 30, 60, 130, ?
Sireesha said:
1 decade ago
Where can I implement the loop in above program give example ?
Sireesha said:
1 decade ago
What will be the output of the program?
int I = 0;
label:
if (I < 2) {
System.out.print("I is " + I);
I++;
continue label;
}
i didn't get any idea y this pgm gives compilation error.and thanks for giving this type of online tests to us.
int I = 0;
label:
if (I < 2) {
System.out.print("I is " + I);
I++;
continue label;
}
i didn't get any idea y this pgm gives compilation error.and thanks for giving this type of online tests to us.
Raju said:
1 decade ago
Continue satatement come under only loops.
for (;;).
for (:).
while ().
do while () ;.
Other than it gives compilation error and if you use break than you can use two other places.
block.
switch.
for (;;).
for (:).
while ().
do while () ;.
Other than it gives compilation error and if you use break than you can use two other places.
block.
switch.
Ranjeet said:
1 decade ago
What is label: here. Please clearly explain?
Ruba said:
1 decade ago
public static void main(String args[])
{
int i=5,j=8;
j=j||(i++&&13);
System.out.println(i);
System.out.println(j);
}
What will be the output of this coding?
{
int i=5,j=8;
j=j||(i++&&13);
System.out.println(i);
System.out.println(j);
}
What will be the output of this coding?
Avinash said:
1 decade ago
What is label here please give clearly explain?
Ashis said:
1 decade ago
What is label: specified in the program?
Riya said:
1 decade ago
@Ramu.
Your answer may be 160 after 130 I think.
Your answer may be 160 after 130 I think.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers