Understanding If Statements in Java

Understanding If Statements in Java

5th Grade

15 Qs

quiz-placeholder

Similar activities

measuring of computer

measuring of computer

5th Grade

13 Qs

Systems Architecture

Systems Architecture

KG - 9th Grade

15 Qs

Self Check Assessment: Web Site Type

Self Check Assessment: Web Site Type

5th Grade

11 Qs

Windows i Linux

Windows i Linux

1st - 5th Grade

15 Qs

Hardware and Software

Hardware and Software

KG - University

10 Qs

Design thinking JC

Design thinking JC

4th - 6th Grade

20 Qs

Microsoft Excel

Microsoft Excel

KG - Professional Development

20 Qs

Coding Quiz

Coding Quiz

3rd - 6th Grade

11 Qs

Understanding If Statements in Java

Understanding If Statements in Java

Assessment

Quiz

Computers

5th Grade

Practice Problem

Hard

Created by

Mohid Atif

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct syntax for an if statement in Java?

if (condition) {}

if condition: {}

if [condition] {}

if condition {}

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is used to compare two strings in Java for equality within an if statement?

==

equals()

compareTo()

Both A and B

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will the following code snippet print? ```java if (5 > 3) { System.out.println("Five is greater than three."); } ```

Five is greater than three.

Error

Nothing

5 > 3

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you correctly check if a string `name` equals "John" in an if statement?

if (name == "John")

if (name.equals("John"))

if ("John".equals(name))

B and C are correct

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code? ```java String a = "Hello"; String b = "hello"; if (a.equals(b)) { System.out.println("Equal"); } else { System.out.println("Not Equal"); } ```

Error

Equal

Not Equal

None of the above

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In Java, which operator is used to check if two values are NOT equal in an if statement?

!=

==

<=

>=

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the following code snippet output? ```java int number = 10; if (number % 2 == 0) { System.out.println("Even"); } else { System.out.println("Odd"); } ```

Odd

Even

Error

None of the above

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?