Chapter Questions
In a UML diagram, what does an asterisk (") indicate?
In a UML diagram, what does a solid diamond indicate?
Explain how using an inheritance hierarchy can lead to code reusability.
What are two synonyms for a superclass?
What are two synonyms for a subclass?
How do you tell the compiler that a particular class is derived from another class?
Based on the UML diagram in Figure $12.9,$ an instance of the Part $\mathrm{T}$ ime class includes the following instance variables: name and id. (T / F)
In a subclass's constructor, what do you have to do if you want to begin the constructor with a call to the superclass's zero-parameter constructor?
If a superclass and a subclass define methods having the same name and the same sequence of parameter types, and an object of the subclass calls the method without specifying which version, Java generates a runtime error. (T / F).
If a subclass method overrides a method in the superclass, is it still possible to call the method in the superclass from the subclass?
If a superclass declares a variable to be private, can you access it directly from a subclass?
If you wish to call a superclass method, you must always prefix the method name with super. (T / F)
A final method is called "final" because it's allowed to contain only named constants, not regular variables. (T / F)
Composition and inheritance are alternative programming techniques for representing what is essentially the same kind of real-world relationship. (T $\overline{/ \mathrm{F}}$ ).
A Deck is a group of cards and a Deck has a group of cards. In our example, it's better to choose the is-a relationship and implement inheritance. In this case, why is inheritance a better choice than composition?
It's possible to support an association with references, variables, and methods in existing classes. What's the advantage of using an association class instead?