Java Conditional Statements

Java Conditional Statements

9th Grade

16 Qs

quiz-placeholder

Similar activities

Java Decision/Selection Self-Check

Java Decision/Selection Self-Check

9th - 12th Grade

20 Qs

STATIC KEYWORD IN JAVA

STATIC KEYWORD IN JAVA

9th - 12th Grade

18 Qs

While and If's (Test4)

While and If's (Test4)

9th - 12th Grade

18 Qs

"switch" Java Statement - 1

"switch" Java Statement - 1

9th - 10th Grade

17 Qs

Java If/else/ switch

Java If/else/ switch

9th - 12th Grade

20 Qs

Arithmetic Types Declare Initialize Relation Logical Ops

Arithmetic Types Declare Initialize Relation Logical Ops

9th Grade - University

16 Qs

Intro to Java Q1 Assessment

Intro to Java Q1 Assessment

9th Grade - University

16 Qs

Java Lab Code.org AP CSA

Java Lab Code.org AP CSA

9th - 12th Grade

18 Qs

Java Conditional Statements

Java Conditional Statements

Assessment

Quiz

Computers

9th Grade

Medium

Created by

Trevor I Stanley

Used 2+ times

FREE Resource

16 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following Java code snippet? ```java int x = 10; if (x > 5) { System.out.println("Greater"); } else { System.out.println("Smaller"); } ```

Smaller

Greater

Error

No output

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is a correct syntax for an if-else statement in Java?

`if (condition) { // code } else (condition) { // code }`

`if (condition) { // code } else { // code }`

`if { // code } else { // code }`

`if (condition) else { // code }`

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Consider the following code: ```java int a = 5, b = 10; if (a < b && b > 5) { System.out.println("Condition met"); } ``` What will be the output?

Condition met

No output

Error

Condition not met

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the result of the expression `!(true && false)` in Java?

true

false

Error

null

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following operators is a comparison operator in Java?

&&

||

==

!

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code? ```java int x = 3; if (x == 3) { if (x > 2) { System.out.println("Nested"); } } else { System.out.println("Not Nested"); } ```

Nested

Not Nested

Error

No output

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which logical operator is used to represent "OR" in Java?

&&

||

!

==

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?