Menu
Question Index
...

What will be the output of the following program?

public class HelloWorld {
    public static void main(String[] args) {
        for (int i = 0; i < 5; i += 1) {
            while (i < 2) {
                System.out.print("While" + ", ");
                break;
            }
            System.out.print("For" + ", ");
            if (i < 3)
                continue;
            else
                break;
        }
    }
}


While, For,
While, For, While, For, For, For,
While, For, While, For, For,
Compilation Error
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