Menu
Question Index
...

What will be the output of the following program?

public class OhMyGod {
    public static void main(String args[]) {
        int x, y;
        skip : for (x = 2; x < 4; x++) {
            System.out.print(x + " ");
            for (y = 0; y < 6; y++) {
                System.out.print(y + " ");
                if (x == y) {
                    break skip;
                }
            }
        }
    }
}


2 0 1 2
2 0 1 3 0 1 2 3
2 0 1 2 3 0 1 2 3
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java for loops vs Java while loops vs Java do while loops

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App