Consider the following program:
class ClassA {}/*from w w w . ja v a 2 s .c om*/ interface InterfaceB {} class ClassC {} class Test extends ClassA implements InterfaceB { String msg; ClassC classC; }
Which one of the following statements is true?
a)Class Test is related with ClassA with a has-a relationship. b)Class Test is related to ClassC with a composition relationship. c)Class Test is related with String with an is-a relationship. d)Class ClassA is related with InterfaceB with an is-a relationship.
b)
When a class inherits from another class, they share an is-a relationship.
On the other hand, if a class uses another class (by declaring an instance of another class), then the first class has a has-a relationship with the used class.