Question: How would you implement a has - a relationship in a class Person to indicate which Dog a person has? Choose the best option that
How would you implement a hasa relationship in a class Person to indicate which Dog a person has?
Choose the best option that applies.IMPORTANT: The penalty scheme for this question is
Question Answer
a
I would add a hasADogmethod to the Personclass.
b
I would add an instance variable of type Dog to the Person class.
c
I would assign a Dog object to a variable of type Person.
d
I would add a parameter of type Dog to the constructor of the Person class.
e
This is not possible as the Dog would overload the Person class.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
