Exercises
9.3 (Recommended: Using Composition Rather Than Inheritance) Many programs written with inheritance could be written with composition instead, and vice versa. Rewrite class
BasePlus–CommissionEmployee
(Fig.9.11 ) of theCommissionEmployee
–BasePlusCommissionEmployee
hierarchy so that it contains a reference to aCommissionEmployee
object, rather than inheriting from classCommissionEmployee
. RetestBasePlusCommissionEmployee
to demonstrate that it still provides the same functionality.9.4 (Software Reuse) Discuss the ways in which inheritance promotes software reuse, saves time during program development and helps prevent errors.
9.5 (
Student
Inheritance Hierarchy) Draw an inheritance hierarchy for students at a university similar ...
Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.