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 has-a 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 33.33,66.67,100%.
Question 13 Answer
a.
I would add a hasADog()method 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!