Multiple choice technology programming languages

Which Man class properly represents the relationship "Man has a best friend who is a Dog"?

  1. class Man extends Dog { }

  2. class Man implements Dog { }

  3. class Man { private BestFriend dog; }

  4. class Man { private Dog bestFriend; }

  5. class Man { private Dog<bestFriend>; }

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The relationship 'Man has a best friend who is a Dog' is a composition/association relationship, modeled by declaring a member variable of type Dog inside the Man class named bestFriend. Inheritance (extends) or interface implementation (implements) would incorrectly state that Man is a Dog.