Page 878 - AP Computer Science A, 7th edition
P. 878

25. (B) Here is the hierarchy of classes:
Eliminate choice D which fails to make DocStudent a subclass of Graduate. This is a poor design choice since a DocStudent is-a Graduate. Making Student an abstract class is desirable since the methods that are common to all students can go in there with implementations provided. The method to calculate the GPA, which differs among student types, will be declared in Student as an abstract method. Then unique implementations will be provided in both the Graduate and Undergraduate classes. Choice A is a poor design because making Student an interface means that all of its methods will need to be implemented in both the Undergraduate and Graduate classes. Many of these methods will have the same implementations.
As far as possible, you want to arrange for classes to inherit common methods and to avoid repeated code. Choice C is slightly inferior to choice B because you are told that all
 































































































   876   877   878   879   880