• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PGJC Exam - clarification?

 
sanjana narayanan
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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
it is mentioned that there are 3 correct answers for this question.
I am sure abt 3 and 5. what is the other option?
-sanjana
 
Ashok Paulraj
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What abt. option 2, Baz is a Foo & Baz has a bar, hence, Foo has a Bar !!
~ Shalini
 
sanjana narayanan
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It did not strike me at all..
Thanks Tauren.

-Sanjana
 
Yosi Hendarsjah
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Taurean, I think your explanation is not quite right. The better explanation is Foo has a Baz and Baz has a Bar so Foo (indirectly) has a bar (whether Baz is a Foo or not).
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Taurean]: Baz is a Foo & Baz has a bar, hence, Foo has a Bar !!
A bird is an animal and a bird has wings, hence, animals have wings!!
Unless of course, they don't.
You could say that some animals have wings, or that some Foo subclasses have a Bar. But that's not really very helpful.
[sanjana]: it is mentioned that there are 3 correct answers for this question.
Nope. 3 and 5 are the only correct answers. If this is from a known mock exam, contact the author to let them know. If there's no way to contact the author, then the mock exam probably isn't reliable anyway; just ignore it.
[ January 21, 2004: Message edited by: Jim Yingst ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic