Hi all, I found this is-a question in my Learn Key mock exam that i don't agree with the answer. The question and the answer are bellow:
A) is-a relationships always rely on inheritance.
B) is-a relationships always rely on instance variables.
C) is-a relationships always require at least two class types.
D) is-a relationships always rely on
polymorphism.
E) is-a relationships are always tighly coupled.
Answers with explanations:
A, C and D are correct. B is incorrect. Inheritance is independent of the existence of instance variables. E is incorrect. Coupling is not used to evaluate classes within the same inheritance tree.
What i think from the answer:
A) A cannot be true because an is-a relationship also applies when a class implements an interface. Example: java.lang.String implements Comparable, then,
String is-a Comparable! there is no inheritance!
C) i don't understand why we can't say that a String is-a String! Isn't it an is-a relationship?
D) i can't get why does is-a always rely on polymorphism, i think that's because of my doubt on letter C.
Can you clarify these with your comments?
Thank you,
Bruno