FINAL
CS202, Summer 2004


Please upload all your files using the turnin server at the end of the exam. Note that you won't be able to upload any file after 10:40AM. Before turn in any program, try to compile and run it and make sure it works correctly. If your program does not even compile, you receive an automatic 50% credit deduction for that problem, no matter how "close" the program seems to be correct.


1.(28pt) Fill in the blank with a correct word to complete the sentence:
2. Give short answers to the following questions:

(a) (22pt) What are the similarity(s) and the difference(s) between an interface and an abstract class?
(b) (10pt) Why polymorphism makes programming "easier"?

3. AddrBook implements a simple address book, where an address entry consists of first name, last name, address, email, and phone number.
For this problem, modify the AddrBook application (including AddrEntry.java if neccessary) as follows:

(a) (15pt) Currently the address book only keeps one address. Modify the code such that it can hold any number of addresses.
(b) (15pt) Add event handling code such that the Next button allows a user to cycle through all entries in the address book.
(c) (15pt) Add a Save menu item to the File menu. When a user clicks on Save, the application saves all entries in the address book to the file addresses.txt.
(d) (15pt) Add an Exit menu item to the File menu. When a user clicks on Exit, the application pops up a dialog box and asks the user whether to save the addresses before exit. Based on the user's response, the application either exits, or saves the addresses then exits.
(e) (20pt) Add event handling code such that the Update button allows a user to add a new entry to the address book, or updates an existing entry, based on whether there is already an entry in the address book that has the same first name and last name.