MIDTERM
CS202, Summer 2006

Please upload all your files and source code to CSNS by the end of the exam. Note that file uploading will be disabled automatically after 11:00AM, and late turnin will not be accepted. 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.


[Q&A] For the following questions, please put your answers in a text file midterm.txt or an MS Word file midterm.doc. For questions that could have multiple correct answers, giving one of the correct answers is enough.

1.(15pt) Fill in the blank with a correct word to complete the sentence:

(a) An object is called                           if its value cannot be changed.
(b) A                           instance variable can be accessed directly by name within the same package or within a subclass.
(c) A method that calls itself is referred to as a                           method.
(d) All user-created classes in Java implicitly inherit from the                           class.
(e) Keyword                           can be used as if it were a method name to invoke a constructor of the same class.

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

(a) What is the difference between overloading and overriding?
(b) Why shouldn't we always make instance variables public?
(c) Briefly explain polymorphism and why it is useful.

[Programming]

3. Suppose you are contracted by a video rental store to development a Java application to process video rentals. You have full freedom to design the classes needed for this application, as long as they meet the following requirements:

(a) (40pt) The classes must be able to store certain information about videos, customers, and rentals. In particular,

(b)  (25pt) The application must also include a program VideoManager.java that allows an employee at the store to

You may use VideoManager.java as a template for your program, and feel free to make any changes to it if necessary. And for simplicity, you may also assume that the input is always correct, e.g. the employee will not try to check out a video that does not exist or has already been rented out.

4. (20pt) Write a Java program which performs the following two operations:

Test your program with the file boxoffice.txt.


The total of the midterm is 100pt. Anything above 100pt is considered extra credit.