Java Reference
In-Depth Information
΢΢ Exercise R12.5. After discovering a method, why is it important to
identify the object that is responsible for carrying out the action?
΢
Exercise R12.6. What relationship is appropriate between the following
classes: aggregation, inheritance, or neither?
a. UniversityÎStudent
b. StudentÎTeachingAssistant
c. StudentÎFreshman
d. StudentÎProfessor
e. CarÎDoor
f. TruckÎVehicle
g. TrafficÎTrafficSign
h. TrafficSignÎColor
΢΢ Exercise R12.7. Every BMW is a vehicle. Should a class BMW inherit from
the class Vehicle ? BMW is a vehicle manufacturer. Does that mean that
the class BMW should inherit from the class VehicleManufacturer ?
΢΢ Exercise R12.8. Some topics on object-oriented programming recommend
using inheritance so that the class Circle extends the class Point . Then
the Circle class inherits th e setLocation method from the Point
superclass. Explain why the setLocation method need not be redefined
in the subclass. Why is it nevertheless not a good idea to have Circle
inherit from Point ? Conversely, would inheriting Point from Circle
fulfill the is-a rule? Would it be a good idea?
579
580
΢
Exercise R12.9. Write CRC cards for the Coin and CashRegister
classes described in Section 8.2 .
΢
Exercise R12.10. Write CRC cards for the Bank and BankAccount
classes in Section 7.2 .
Search WWH ::




Custom Search