(Java)
An Account object contains a String object representing the account owner’s name, an Address object representing the owner’s home address and the bank location. What kind of class relationship is this?
A.
Dependency
B.
Aggregation
C.
Association
D.
Inheritance
Expert Answer
Answer is B. Aggregation
Class Account has an instance of class Address. This is a kind of association relationship. But the relationship is unidirectional only. Account is having HAS-A relationship on Address.
In any case Address cannot have HAS-A relationship with Account. This is a special case of Association which is called Aggregation