Search Header Logo

Learning-Focused MCQs on Java if-else

Authored by Dina Sharawy

Education

11th Grade

Used 4+ times

Learning-Focused MCQs on Java if-else
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the main purpose of an if statement in Java?

To repeat a block of code multiple times.

To check a condition and execute code only if it's true.

To execute a block of code without any conditions.

To sort data in a specific order.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will this code print if int x = 10;?

if (x > 5) {

    System.out.println("x is greater than 5");

}

x is greater than 5

x is less than 5

Nothing will print

x is equal to 5

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

When would you use an else statement in Java?

To execute code if the if condition is true.

To execute code if the if condition is false.

To stop the program entirely.

To skip over a condition without checking it.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will this code output if int age = 17;?

if (age >= 18) {

    System.out.println("Adult"); }

else {

    System.out.println("Minor"); }

Adult

Minor

Nothing

Error

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In an if-else ladder, what happens if the first if condition is true?

All following conditions are also checked.

Only the else statement runs.

The program skips all following else if and else conditions.

None of the statements execute.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does this code snippet print if int score = 75;?

if (score >= 90)

{ System.out.println("Grade A");}

else if (score >= 80)

{ System.out.println("Grade B");}

else if (score >= 70)

{System.out.println("Grade C");}

else

{System.out.println("Grade D or below");}

Grade A

Grade B

Grade C

Grade D or below

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following correctly describes nested if statements?

if statements placed one after another.

An if statement with no else condition.

An if statement inside another if or else block.

Multiple else statements in a row.

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?