Stairway to Heaven -- The CS 120 Final
0) Is your name on the test?
a) Yes it is.
b) Yes it will be.
c) No I don't want credit for this test.
d) I'm so nervous I forgot my name.
1) How many times does this loop draw a rectangle?
int i = 1;
while (i < 10) {
g.drawRect(10*i, 10*i, 3, 3);
i=i*3 - 1;
}
2) Does the loop above draw rectangles ...
a) Hoizontally
b) Vertically
c) Diagnolly
d) None of the above
3) Name an error in a program that could cause a "null pointer exception".
4) How many circles does this code draw?
for(int i = 0; i < 5; i++)
for(j = 0; j < 6; j++)
g.fillOval(i*20, j*20, 6, 6);
5) Where is the center of the first circle drawn by the code above?
6) Except for the US, Canada and England, name any country that speaks English.
7) Suppose I allocate an array as shown below. How many elements does
it have?
question6 = new String[10][20];
a) 1
c) 200
e) 10
b) 2
d) 20
f) None of the above
Choose either program 1 or 2, and show me it running.
Choose either program 3 or 4, and show me it running.
Program 1: The Balance Beam
Shows a balance beam: 3 points
Clicking changes the number: 3 points
Shows an arrow describing the heavier side: 3 points
Tilts to the heavier side: 3 points
Program 2: The Number Line
Shows a number lines: 3 points
Tells you "hot or cold": 3 points
Tells when you find the magic spot: 3 points
Program 3: Star Burst
Draws the center of the starburst: 2 points
Draws each ray: 3 points
Each ray is a different color: 2 points
Can repaint the screen and everything is OK: 3 points
Program 4: The Smiley Faces
Draws a smiley face: 3 points
Knows where you clicked: 3 points
Draws smiley faces where you clicked: 3 points
Can repaint the screen and everything is OK: 3 points