MIDTERM
CS202, Summer 2004


Please print out a hard copy of all your files and turn it in at the end of the exam. Do not forget to put your name on the hard copy. Before turn in your programs, try to compile and run them and make sure they work 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.(15pt) Fill in the blank with a correct word to complete the sentence:

2. (14pt) Use no more than three sentences to answer each of the following questions:

3. (16pt) Give one code example that shows overloading, overriding, and dynamic dispatching in the same example. Use code comments to indicate where overloading, overriding, or dynamic dispatching takes place. Note that your example may consist of multiple classes.


4. A class roster in the GET system is a list of student records, and each student record is in the following format:
LastName,FirstName    [OptionalMiddleName]    StudentID    College
A sample file of a class roster can be found here. For simplicity, we assume that a) no class has more than 8 students, b) a student ID is a 9-digit number which starts with 2, and c) two students may have the same name, but student IDs are unique.

(a) (15pt) Write a Java class Student which holds the information of a student. The implementation of the class is up to you, but the Student class must provide at least the following method(s):
(b) (40pt) Write a Java class Roster which holds the student records of a class. Again the implementation is up to you, but the Roster class must provide at least the following method(s):
John Doe
Mary Watson
Peter Parker
Test your Student and Roster classes with the sample roster file and the test program RosterTest.java