Java Software Solutions, 8e, Global Edition
Exercise Solutions, Ch. 10
Chapter 10 Exercise Solutions
EX 10.1. Draw and annotate a class hierarchy that represents various types of
faculty at a university. Show what characteristics would be represented in the
various classes of the hierarchy. Explain how polymorphism could play a role in
the process of assigning courses to each faculty member.
The abstract method assignCourses is established in the FacultyMember class,
ensuring that child classes will implement it. That way, each class can have a definition
EX 10.2. Draw and annotate a class hierarchy that represents various types of
animals in a zoo. Show what characteristics would be represented in the various
classes of the hierarchy. Explain how polymorphism could play a role in guiding
the feeding of the animals.
Java Software Solutions, 8th Edition Exercise Solutions, Ch. 10
The abstract method feedingInstructions is established in the ZooAnimal class,
ensuring that child classes will implement it. That way, each class can have a definition
of feedingInstructions that makes sense for it. A program that manages a list of
EX 10.3. Draw and annotate a class hierarchy that represents various types of sales
transactions in a store (cash, credit, etc.). Show what characteristics would be
represented in the various classes of the hierarchy. Explain how polymorphism
could play a role in the payment process.
The following diagram is a modified version of the one used for Exercise 9.7.
Java Software Solutions, 8th Edition Exercise Solutions, Ch. 10
The abstract method purchase is established in the Sale class, ensuring that child
EX 10.4. What would happen if the pay method were not defined as an abstract
method in the StaffMember class of the Firm program?
By defining the pay method in StaffMember, all child classes must implement it (or
EX 10.5. Explain how a call to the addMouseListener method represents a
polymorphic situation.
The addMouseListener method was written years ago by a Sun Microsystems API
programmer, long before any particular class you write to serve as a mouse listener.
Java Software Solutions, 8th Edition Exercise Solutions, Ch. 10
EX 10.6. Draw the containment hierarchy for the SlideColor program.