Easy Tutorial
For Competitive Exams

What is the output of this program?
class Output {
public static void main(String args[])
{
int a = 5;
int b = 10;
first: {
second: {
third: {
if (a == b >> 1)
break second;
}
System.out.println(a.;
}
System.out.println(b.;
}
}
}

5 10
10 5
5
10
Explanation:
b >> 1 in if returns 5 which is equal to a i:e 5, therefore body of if is executed and block second is exited.
Control goes to end of the block second executing the last print statement, printing 10.
output:
$ javac Output.java
$ java Output
10
Share with Friends
Privacy Copyright Contact Us