Java Software Solutions, 8e, Global Edition
Exercise Solutions, Ch. 9
Chapter 9 Exercise Solutions
EX 9.1. Draw a UML class diagram showing an inheritance hierarchy containing classes
that represent different types of clocks. Show the variables and method names for
two of these classes.
EX 9.2. Show an alternative diagrm for the hierarchy in Exercise 9.1. Explain why it may be
a better or worse approach than the original.
Java Software Solutions, 8th Edition Exercise Solutions, Ch. 9
EX 9.3. Draw a UML class diagram showing an inheritance hierarchy containing classes
that represent different types of cars, organized first by manufacturer. Show some
appropriate variables and method names for at least two of these classes.
EX 9.4. Show an alternative diagram for the hierarchy in Exercise 9.3 in which the cars are
organized first by type (sports car, sedan, SUV, etc.). Show some appropriate
variables and method names for at least two of these classes. Compare and
contrast the two approaches.
Java Software Solutions, 8th Edition Exercise Solutions, Ch. 9
The hierarchy in Ex. 9.3 has the manufacturer information as an inherent part of the
EX 9.5. Draw a UML class diagram showing an inheritance hierarchy containing classes
that represent different types of airplanes. Show some appropriate variables and
method names for at least two of these classes.
EX 9.6. Draw a UML class diagram showing an inheritance hierarchy containing classes
that represent different types of trees (oak, elm, etc.). Show some appropriate
variables and method names for at least two of these classes.
Java Software Solutions, 8th Edition Exercise Solutions, Ch. 9
EX 9.7. Draw a UML class diagram showing an inheritance hierarchy containing classes
that represent different types of transactions at a store (cash, credit card, etc.).
Show some appropriate variables and method names for at least two of these
classes.
EX 9.8. Experiment with a simple derivation relationship between two classes. Put println
statements in constructors of both the parent and child classes. Do not explicitly
call the constructor of the parent in the child. What happens? Why? Change the
Java Software Solutions, 8th Edition Exercise Solutions, Ch. 9
child’s constructor to explicitly call the constructor of the parent. Now what
happens?
When a parent’s constructor is explicitly called, its program statements are executed as