wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Java Chapter 3 Review Questions

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

The if statement is an example of a

a)

sequence structure

b)

decision structure

c)

pathway structure

d)

class structure

2.

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

a)

binary expression

b)

decision expression

c)

unconditional expression

d)

boolean expression

3.

>, <, and == are

a)

relational operators

b)

logical operators

c)

conditional operators

d)

ternary operators

4.

&&, ||, and ! are

a)

relational operators

b)

logical operators

c)

conditional operators

d)

ternary operators

5.

This is an empty statement that does nothing

a)

missing statement

b)

virtual statement

c)

null statement

d)

conditional statement

6.

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

a)

parentheses ()

b)

square brackets []

c)

angled brackets <>

d)

braces {}

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 greater than 'B'

b)

'A' is less than 'B'

c)

'A' is equal to 'B'

d)

You cannot compare characters

9.

This is an if statement that appears inside another if statement

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 == operator

b)

the = operator

c)

the equals method

d)

the stringCompare method

13.

The conditional operator takes this many operands

a)

one

b)

two

c)

three

d)

four

14.

This section of a switch statement is branched to if none of the case values match the testExpression

a)

else

b)

default

c)

case

d)

otherwise

15.

When using arrow case syntax in a switch statement, the arrow operator is

a)

==>

b)

=>

c)

->

d)

>>

16.

If a case section in a switch expression has more than one statement, you must use the __________ keyword to return a value that case section.

a)

return

b)

yield

c)

val

d)

eval

17.

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

a)

Format.out.println

b)

Console.format

c)

System.out.printf

d)

System.out.formatted

18.

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

a)

True

b)

False

19.

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

a)

True

b)

False

20.

All lines in a conditionally executed block should be indented one level

a)

True

b)

False

21.

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

22.

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)

True

b)

False

23.

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

a)

True

b)

False

24.

When you write a switch statement using the arrow case syntax, you must have a break statement in each case section

a)

True

b)

False

25.

When using arrow case syntax in a switch statement, if you need to write more than one statement in a case section, you must enclose those statements in curly braces

a)

True

b)

False