wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Java Ch 3 Decision Structures

Total questions: 26

Worksheet time: 13mins

Name
Class
Date
1.

The if statement is an example of a _____.

a)

decision structure

b)

sequence structure

c)

pathway structure

d)

class structure

2.

This type of expression has a value of either true or false.

a)

boolean expression

b)

binary expression

c)

discussion expression

d)

unconditional expression

3.

>, <, and == are _____.

a)

relational operators

b)

logical operators

c)

conditional operators

d)

ternary operators

4.

&&, ||, and ! are _____.

a)

logical operators

b)

relational operators

c)

conditional operators

d)

ternary operators

5.

This is an empty statement that does nothing.

a)

null statement

b)

missing statement

c)

virtual statement

d)

conditional statement

6.

To create a block of statements, you enclose the statements in these.

a)

braces { }

b)

parathensis ( )

c)

square brackets [ ]

d)

angled brackets < >

7.

This is a boolean variable that signals when some condition exists in the program.

a)

flag

b)

signal

c)

sentinel

d)

siren

8.

How does the character 'A' compare to the character 'B'?

a)

'A' is less than 'B'

b)

'A' is greater than 'B'

c)

'A' is equal to 'B'

d)

You cannot compare characters

9.

An if statement inside another if statement is called a _____.

a)

nested if statement

b)

tiered if statement

c)

dislodged if statement

d)

structured if statement

10.

An else clause always goes with _____.

a)

the closest previous if clause that doesn't already have its own else clause

b)

the closest if clause

c)

the if clause that is randomly selected by the compiler

d)

None of these

11.

When determining whether a number is inside a range, it's best to use this operator.

a)

&&

b)

||

c)

!

d)

?

12.

This determines whether two different String objects contain the same string.

a)

the equals method

b)

the == operator

c)

the = operator

d)

the stringCompare method

13.

The conditional operator takes this many operands.

a)

three

b)

one

c)

two

d)

four

14.

This section of a switch statement is branched to if none of the case expressions match the switch expressions.

a)

default

b)

else

c)

case

d)

otherwise

15.

You can use this method to display formatted output in a console window.

a)

System.out.printf

b)

System.out.formatted

c)

Console.format

d)

Format.out.println

16.

The = operator and == operator perform the same operation.

a)

False

b)

True

17.

A conditionally executed statement should be indebted one level from the if clause.

a)

True

b)

False

18.

All lines in a conditionally executed block should be indebted one level.

a)

True

b)

False

19.

When an if statement is nested in the if clause of another statement, the only time the inner if statement is executed is when the boolean expression of the outer if statement is true.

a)

True

b)

False

20.

When an if statement is nested in the else clause of another statement, the only time the inner if statement is executed is when the boolean expression of the outer if statement is true.

a)

False

b)

True

21.

A flag may have the values

a)

defined or undefined

b)

true or false

c)

of any range of integers

d)

of any Unicode character

22.

To determine if a char is not equal to a value what expression would you use?

a)

chrX == 'X'

b)

chrX != 'X'

c)

chrX || 'X'

d)

chrX.notEquals('X')

23.

In Java, when a character is stored in memory, it is actually the ____ that is stored.

a)

Unicode number

b)

ASCII code

c)

floating-point value

d)

letter, symbol, or number

24.

If you prematurely terminate an if statement with a semicolon, the compiler will

a)

not display an error message

b)

assume you are placing a null statement there

c)

both (a) and (b)

d)

none of these

25.

If the expression on the left side of the && operator is false, the expression on the right side won't be checked is an example of

a)

short-circuit evaluation

b)

reverse logic

c)

Boolean logic

d)

relational evaluation

26.

The scope of a variable is limited to the block in which it is defined.

a)

True

b)

False