Answers to Self-Review Exercises (Sections G.1G.5)
-
Inheritance.
public
andprotected
.is-a or inheritance.
has-a or composition.
hierarchical.
public
.constructor.
super
.
-
True.
False. A has-a relationship is implemented via composition. An is-a relationship is implemented via inheritance.
False. This is an example of a has-a relationship. Class
Car
has an is-a relationship with classVehicle
.False. This is known as overriding, not overloading—an overloaded method has the same name, but a different signature.
Get Android How to Program, 3/e 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.