Forums Register Login

HAS-A relation

+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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 ]
For my next trick, I'll need the help of a tiny ad ...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 793 times.
Similar Threads
Has-A relationship
khalid mughal's test
IS-A and HAS-A Relationship Doubts
PGJC Exam - clarification?
Exam question - is a , has a- help!
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:00:58.