Menu
Question Index
...

What will be the output of the following program?

public class DemoOnBreak
{
    public static void main(String[] args)
    {
        Boolean b = 21 >= 21;
        block1 :
        {
            block2 :
            {
                block3 :
                {
                    if (b)
                        break block2;
                    System.out.println("BLOCK3");
                }
                System.out.println("BLOCK2");
            }
            System.out.println("BLOCK1");
        }
    }
}


BLOCK1
BLOCK3
BLOCK3
BLOCK3
BLOCK2
BLOCK1
BLOCK1
Compilation Error or Runtime Error

Doubts

Problems

Topic: Using break In Nested Loop Java Program

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App