A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/quizzes/java-control-statements-and-loops/ below:

Quiz about Java Control Statements and Loops

What will be the output of the following code?

Java
int x = 5;
if (x > 2)
    if (x > 4)
        System.out.println("A");
    else
        System.out.println("B");

Which of the following is NOT a valid control statement in Java?

What will be the output of the following loop?

Java
for (int i = 0; i < 3; i++) {
    System.out.print(i + " ");
}

How many times will the following loop execute?

Java
int i = 1;
while (i <= 5) {
    System.out.println("Hello");
}

What is the output of the following Java code?

Java
for (int i = 0; i < 5; i++) {
    if (i == 2)
        break;
    System.out.print(i + " ");
}

What will be the output of this code?

Java
for (int i = 0; i < 5; i++) {
    if (i == 3)
        continue;
    System.out.print(i + " ");
}

What will happen if the condition in a for loop is omitted?

Java
for (int i = 0; ; i++) {
    System.out.println(i);
}

What is the correct syntax for a do-while loop in Java?

What will be the output of the following nested loop?

Java
for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 2; j++) {
        System.out.print(i + "," + j + " ");
    }
}

What will be the output of the following while loop?

Java
int x = 10;
while (x > 0) {
    x -= 3;
    System.out.print(x + " ");
}

There are 10 questions to complete.

Take a part in the ongoing discussion


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4