Given :
A. class Man extends Dog { }
B. class Man implements Dog { }
C. class Man { private BestFriend dog; }
D. class Man { private Dog bestFriend; }
E. class Man { private Dog<bestFriend>; }
F. class Man { private BestFriend<dog>; }
Answer: D
A. class Man extends Dog { }
B. class Man implements Dog { }
C. class Man { private BestFriend dog; }
D. class Man { private Dog bestFriend; }
E. class Man { private Dog<bestFriend>; }
F. class Man { private BestFriend<dog>; }
Answer: D
Explanation:
If the Class has entity reference then it is called Aggregation.Aggregation is also known for "HAS - A" relationship.
In the above question we have "Man has a best friend " which represents container-ship or "HAS-A" relationship . Therefore bestFriend is one of the Member of Man .
In the above question we have "Man has a best friend " which represents container-ship or "HAS-A" relationship . Therefore bestFriend is one of the Member of Man .
"Who is a Dog".This part may confuses us ,but in the question it is very much clear in stating that best friend is of type Dog . So Datatype is Dog and variable name is bestFriend .
Since we have Dog bestFriend as a data member of Man ,therefore Man has to be a Class which has this data member which satisfies "HAS-A" relationship.
Option D.
0 comments:
Post a Comment