Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question about "has a" at SUN's mock exam

 
dragon ji
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
10. class A {}
11. class B {
12. private A myA = new A();
13. }
Which two statements are true about the relationship between class A and class B? (Choose two.)

A
A maintains no relationship with B
B
B maintains no relationship with A
C
B maintains a "one to many" relationship with A
D
The relationship can be described with a has-a clause
E
The relationship can be described with an is-a clause
Answer:
Options A and D are the correct answers
but I think it should be option C and D,please explain it to me,thanx.
 
Chloe Loh
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason that...
A is true:
In the example here, classB holds one classA object, which creates 'has a' relationship that classB has an object of classA but this relationship is not maintained by classA but classB since class A doesn't hold any information of this relationship and no change need to be made on classA should the relationship of these two classes be changed.
C is false:
There will be only one classA object be created when a classB object is created. It is a " one to one" relationship exists in this example but not "one to many".
I hope this will help....
 
dragon ji
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot,Chloe!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic