Answers to Self-Review Exercises

9.1
  1. Inheritance.

  2. public and protected.

  3. is a or inheritance.

  4. has-a or composition.

  5. hierarchical.

  6. public.

  7. constructor.

  8. super.

9.2
  1. True.

  2. False. A has-a relationship is implemented via composition. An is a relationship is implemented via inheritance.

  3. False. This is an example of a has-a relationship. Class Car has an is a relationship with class Vehicle.

  4. True.

  5. False. This is known as overriding, not overloading—an overloaded method has the same name, but a different signature.

Get Java™ How to Program, Seventh 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.