Closed-book. You should have a single "cheat sheet" of notes and a calculator. You may not use any computers or access the internet. No cell phones or wireless communication may be used.

Print Name ____________________________________ Last four digits of SID. _____________























There are 10 questions each worth a maximum of 20 points. Attempt as many questions as you can. Partial answers count. Blank answers score the same as wrong ones -- zero. Answer as much of every question as you can and do not erase your working.

Put all your answers in the spaces provided on these sheets of paper.

1Your Project...

2.Arithmetic Look at the following deliberately obscure program.

(a) Find and correct the one syntax error and fix it.

(b) Find one variable that has not been initialized before it is used. Change program so that it is set to 10.0 initially.

(c) Walk through the resulting program using a calculator and the table below. Put the instructions and values of variables in the correct columns. Do not erase any working.

3. Strings. What is output by this program (5 points for each correct line)? Be careful -- work it out step by step. Do not guess. Do not erase any working.

4. If-else. The following program compiles and runs. Work out what it does ...

5. Booleans (a) Complete the truth table below (1 point per blank, 8 points max)

(b) The next program has errors in it. ...

6. Functions and for loops Work out, carefully, what the following program outputs when run....

7. Loops This was once a working program that .... I have replaced certain pieces by blanks of random length like this _______. Fill in the blanks with the things I deleted.

8. Objects (a) Fill in the comments with the correct phases from this list:

              accessor, class name, constructor, data field, mutator

(b) Write down the output when the program is run....

9. Coding classes from the UML. Fill in the blanks in the code below so that it implements the class shown in the UML diagram.

10. Vectors and arrays. Complete the program below, fill in the blanks...