Search Header Logo

Java Control Statements MCQs

Authored by Mohd. Khan

Computers

University

Used 1+ times

Java Control Statements MCQs
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

30 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

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

A

B

Compilation error

No output

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

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

0 1 2

1 2 3

0 1 2 3

Infinite loop

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

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

10 7 4 1

10 7 4

10 7

Infinite loop

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

for (int i = 1; i <= 5; i++) { if (i == 3) break; System.out.print(i + " "); }

1 2 3

1 2

1 2 3 4 5

3

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

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

1 2 2 4 3 6

1 2 4 8 12

1 2 2 3 3 4

1 1 2 2 3 3

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

int x = 4; switch (x) { case 1: System.out.println("One"); case 2: System.out.println("Two"); default: System.out.println("Default"); }

One

Default

Two Default

Default only

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

int i = 1; while (i <= 5) { if (i == 3) continue; System.out.print(i + " "); i++; }

1 2 3 4 5

1 2 4 5

Infinite loop

1 2 3 4

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?

Discover more resources for Computers