1. The logical structure in which one instruction occurs after another with no branching is a ______A______.
a. sequence
b. selection
c. loop
d. case
2. Which of the following is typically used in a flowchart to indicate a decision? C.
a. square
b. rectangle
c. diamond
d. oval
3. Which of the following is not a type of if statement? C.
a. single-alternative if
b. dual-alternative if
c. reverse if
d. nested if
4. A decision is based on a(n) _____A_______ value.
a. Boolean
b. absolute
c. definitive
d. convoluted
5. In Java, the value of (4 > 7) is ______C______.
a. 4
b. 7
c. true
d. false
6. Assuming the variable q has been assigned the value 3, which of the following statements prints XXX? A.
a. if(q > 0) System.out.println("XXX");
b. if(q > 7); System.out.println("XXX");
c. Both of the above statements print XXX.
d. Neither of the above statements prints XXX.
7. What is the output of the following code segment? C.
t = 10;
if(t > 7)
{
System.out.print("AAA");
System.out.print("BBB");
}
a. AAA
b. BBB
c. AAABBB
d. nothing
Because the tested expression is true, both statements in the block execute.
8. What is the output of the following code segment? C.
t = 10;
if(t > 7)
System.out.print("AAA");
System.out.print("BBB");
a. AAA
b. BBB
c. AAABBB
d. nothing
The tested expression is true, so AAA prints. The second print statement is a stand-alone statement, so BBB also prints.
9. What is the output of the following code segment? D.
t = 7;
if(t > 7)
System.out.print("AAA");
System.out.print("BBB");
a. AAA
b. BBB
c. AAABBB
d. nothing
The tested expression is false, so AAA does not print. The statement that prints BBB is not