File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes question about Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "question about "has a" at SUN Watch "question about "has a" at SUN New topic

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

dragon ji
Ranch Hand

Joined: Oct 31, 2002
Posts: 110
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 maintains no relationship with B
B maintains no relationship with A
B maintains a "one to many" relationship with A
The relationship can be described with a has-a clause
The relationship can be described with an is-a clause
Options A and D are the correct answers
but I think it should be option C and D,please explain it to me,thanx.

scjp 1.4<br />challenge haven't limit!
Chloe Loh

Joined: Aug 27, 2002
Posts: 22
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

Joined: Oct 31, 2002
Posts: 110
thanks a lot,Chloe!
I agree. Here's the link:
subject: question about "has a" at SUN's mock exam
It's not a secret anymore!