In K&B book,P158, self
test 1):
A Has-a relationships always rely on inheritance.
B Has-a relationships always rely on instance variables.
C Has-a relationships always require at least two class type.
D Has-a relations always rely on
polymorphism.
E Has-a relationship are always tightly coupled.
The given answer is B and I can tell others are obviously wrong.
However, In K&B bonus master exam, we have the following question:
A Has-a relationships are, by definition, well encapsulated.
B A covariant return requires the existence of a has-a relationship.
C Overriding requires the existence of a is-a relationship.
D In some cases, is-a relationships are used in the process of autoboxing.
E Has-a relationships are always defined with instance variables.
The given answer is C&&D. According to the self test question, I think E is also the right answer. The explanation is that class (static) variables can also be used to define has-a relationships.
Therefore, I think these two question are contradictory to one another. Could anyone help me clear this?