Menu
Question Index
...

What is the output of the following program?

public class LoopTest {
    public static void main(String[] args) {
        int x = 0;
        out : for (int i = 0; i <= 5; i++) {
            for (int j = 0; j <= 49; j++) {
                if (i == 2)
                break out;
                x++;
            }
        }
        System.out.println("x = " + x);
    }
}


x = 5
x = 49
x = 99
x = 100

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