NEW
Font size
S
M
L
XL
WorksheetsUnit 5 Review
Total questions: 18
Worksheet time: 18mins
Name
Class
Date
1.
The logical structure in which one instruction occurs after another with no branching is a ____________.
a)
sequence
b)
collection
c)
loop
d)
case
2.
Which of the following is typically used in a flowchart to indicate a decision?
a)
square
b)
rectangle
c)
oval
d)
diamond
3.
Which of the following is not a type of if statement?
a)
single-alternative
b)
dual-alternative
c)
reverse
d)
nested
4.
A decision is based on a(n) ____________ value.
a)
Boolean
b)
absolute
c)
definitive
d)
convoluted
5.
In Java, the value of (14 > 7) is ____________.
a)
true
b)
false
c)
14
d)
7
6.
Assuming the variable score has been assigned the value 9, which of the following statements displays XXX?
a)
if(score <= 9) System.out.println("XXX");
b)
if(score > 9); System.out.println("XXX");
c)
if(score > 0); System.out.println("XXX");
d)
All of the above display XXX.
7.
What is the output of the following code segment?<br />t = 10;<br />if(t > 7)<br />{<br /> System.out.print("AAA");<br /> System.out.print("BBB");<br />}
a)
AAA
b)
BBB
c)
AAABBB
d)
nothing
8.
What is the output of the following code segment?<br />t = 0;<br />if(t > 7)<br /> System.out.print("AAA");<br /> System.out.print("BBB");
a)
AAA
b)
BBB
c)
AAABBB
d)
nothing
9.
When you code an if statement within another if statement, the statements are ____________.
a)
notched
b)
nested
c)
nestled
d)
sheltered
10.
The operator that combines two conditions into a single Boolean value that is true only when both of the conditions are true is ____________.
a)
$$
b)
&&
c)
||
d)
!!
11.
The operator that combines two conditions into a single Boolean value that is true when at least one of the conditions is true is ____________.
a)
||
b)
!!
c)
$$
d)
&&
12.
Assuming a variable f has been initialized to 5, which of the following statements sets g to 0?
a)
if(f > 6 || f == 5) g = 0;
b)
if(f < 3 || f > 4) g = 0;
c)
if(f >= 0 || f < 2) g = 0;
d)
All of the above statements set g to 0.
13.
Which of the following has the lowest precedence?
a)
<
b)
==
c)
&&
d)
||
14.
Which of the following statements correctly outputs the names of voters who live in district 6 and all voters who live in district 7?
a)
if(stuId < 1000) if(stuId > 9999) System.out.println("Error");
b)
if(stuId < 1000 && stuId > 9999) System.out.println("Error");
c)
if(stuId < 1000) System.out.println("Error"); else if(stuId > 9999) System.out.println("Error");
d)
Two of these are correct.
15.
You can use the ____________ statement to terminate a switch statement.
a)
switch
b)
break
c)
case
d)
end
16.
Which of the following cannot be the argument tested in a switch statement?
a)
int
b)
char
c)
double
d)
String
17.
Assuming a variable w has been assigned the value 15, what does the following statement do? w == 15 ? x = 2 : x = 0;
a)
assigns 15 to w
b)
assigns 2 to x
c)
assigns 0 to x
d)
nothing
18.
Assuming a variable y has been assigned the value 6, the value of !(y < 7) is ____________.
a)
6
b)
7
c)
true
d)
false
Reset
