Name____________________
Pop Quiz 3/5/2008
Question 1 is supposed to be very easy if you did the reading and nearly
impossible if you didn't.
1._______ Which of the following was the example the book used for nested
loops?
A. Computing a list of fibbonacci numbers
B. Drawing a triangle of square brackets
C. Printing a multiplication table
D. Finding values in a 2D array
E. Trick questions--the reading was only on non-nested loops
2._______ What does this code print?
int a = 0;
for(int i = 1; i < 4; i++){
a = a + i;
}
System.out.println(a);
A. 0
B. 4
C. 6
D. 10
E. Nothing—It will loop forever
3._______ Why won't this code compile?
int a = 0;
while a < 3
a++;
A. It's missing ;
B. It's missing ()
C. It's missing {}
D. It's not indented correctly
E. The < operator returns an int