Menu
Topics Index
...
`

Print different statements2209


If you need explanation Read this topic

If you need Answer Take test on this topic

Print different statements2209
What will be the output of the following program?
public class TwoInOneBook {
    public static void main(String[] args) {
        boolean b = true;
        One : {
            Two : {
                Book : {
                    System.out.println("Book block");
                    break Two;
                }
                System.out.println("Two block");
            }
            System.out.println("One block");
        }
        System.out.println("Main block");
    }
}

A. Book block
Two block
One block
Main block
B. Book block
One block
Main block
C. Compilation Error
D. Runtime Error
Topic: Using Java Break Statements as Java Goto

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

C. We are breaking Two block before and trying to print statement after break statement in Two Block which cant be reached.

Posted by Nikhil Sulibhavi    2014-04-10 12:52:32


ans is c because two block stmt is unreachable

Posted by Adithya Aleti    2014-04-10 12:53:31


Ans is C the Two block is breaked before print statement so compilation error take place

Posted by Bharath Yelchuri    2014-04-10 12:56:49


answer is C .bcz Block Two is breaked so the rest blocks are printed

Posted by Asad Ahmed    2014-04-10 12:58:26


ans is b bcz when v break two block it comes out and prints one block and main block

Posted by Pooja Singh    2014-04-10 13:21:05


Congratulations Bharath Yelchuri. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-04-11 04:26:37


© meritcampus 2019

All Rights Reserved.

Open In App