Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes HAS-A relation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "HAS-A relation" Watch "HAS-A relation" New topic
Author

HAS-A relation

Sarma Lolla
Ranch Hand

Joined: Oct 21, 2002
Posts: 203
Q36
Which statements concerning the relationships between the following classes are true?
class Foo {
int num;
Baz comp = new Baz();
}
class Bar {
boolean flag;
}
class Baz extends Foo {
Bar thing = new Bar();
double limit;
}
1) A Bar is a Baz.
2) A Foo has a Bar.
3) A Baz is a Foo.
4) A Foo is a Baz.
5) A Baz has a Bar.
The correct answers mentioned are 3,5.
My answers are 2,3,5.
Can any one explain why answer 2 is wrong?
Larry Jones
Greenhorn

Joined: Oct 22, 2002
Posts: 24
Foo dosen't have-a Bar.
In the code below, Foo has a Bar:

Baz, which extends Foo, has a Bar. But in OO terms, Foo does not have-a Bar.
For a has-a relationship, either a class, or a superclass must have a member that is a reference to the object.
[ March 13, 2003: Message edited by: Larry Jones ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HAS-A relation
 
Similar Threads
IS-A and HAS-A Relationship Doubts
Exam question - is a , has a- help!
PGJC Exam - clarification?
khalid mughal's test
Has-A relationship