CS122 Final Exam May 1, 2006 CS122 Final Exam has four multiple-answer questions and one programming question. The topics include class declaration, abstract classes, interfaces, and polymorphism. It is an open-book exam. You have 90 minutes to complete the exam. 1) A class constructor is for [15%] a) initializing object data fields b) releasing computing resources c) conducting any computing at the start of an object's life d) building a class's source code 2) A class implemmenting an interface means [15%] a) the class has a particular graphic user interface b) the class implements all the methods of the interface c) the reference variables declared with the interface can hold the references of the class's objects d) the class inherits some function implementations 3) Abstract class is useful because it {15%] a) factors out the common data fields and method implementations of many similar related classes b) lets programmers avoid low-level programming c) enforces that all of its derived classes must implement some methods d) can instantiate objects easier 4) Polymorphism means that [15%] a) an object can invoke methods of different objects b) a class can contain different objects for its internal implementation c) the actual method implementation invoked against a reference variable is the one whose containing object's reference is saved in the variable at the invocation time d) method invocation can be more efficient 5) Write a complete class that takes a sequence of strings as its command-line arguments, sorts them, and prints them on separate lines. [40%]