wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JAVA CONDITIONAL STATEMENTS

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which of the following conditional statements is used to specify a block of code to be executed, if the same condition is false?

a)

if

b)

else

c)

else if

d)

switch

2.

The switch expression is evaluated ONCE.

a)

TRUE

b)

FALSE

3.

In a switch statement, if there is no match, the FIRST case code block is executed.

a)

TRUE

b)

FALSE

4.


Given the code, what will be the output if x = 10?

a)

TAMA

b)

MALI

c)

NONE

d)

ERROR

5.


Given the code, what will be the output if patientBmi = 26?

a)

Underweight

b)

Normal

c)

Overweight

d)

Obese

6.


Given the code, what will be the output if patientBmi = 18.49?

a)

Underweight

b)

Normal

c)

Overweight

d)

Obese

7.


Given the code, what will be the output if patientBmi = 30?

a)

Underweight

b)

Normal

c)

Overweight

d)

Obese

8.


Given the code, what will be the output if ans = C;

a)

Correct answer

b)

Wrong answer

c)

Invalid answer

d)

Wrong answer

Invalid answer

9.

Given the code, what will be the output if ans = B;

a)

Correct answer

b)

Wrong answer

c)

Invalid answer

d)

Wrong answer

Invalid answer

10.

Given the code, what will be the output if ans = D;

a)

Correct answer

b)

Wrong answer

c)

Invalid answer

d)

Wrong answer

Invalid answer