# one mock exam question from K&B book

Phone Myat Kyaw
Ranch Hand
Posts: 31
Hi, I'm going to sit the SCJP 6.0 exam tomorrow and I'm doing my final preparation. Here's one question make me confusing.

1. class Zing {
2. Hmpf h;
3. }
4. class Woop extends Zing{}
5. class Hmpf { Zing z; }
Which is true? (Choose all that apply.)

Zing has-a Hmpf and Woop is-a Zing.
Hmpf has-a Zing and Woop has-a Hmpf.

I completely understand the first one - Zing class has a Hmpf ref while Woop is inherited from Zing.
But I don't understand why the second answer is correct. What I see is, the first part, Hmpf has-a Zing, is true
but the latter is not. But the mock test I'm taking (from the K&B book) give both are correct.

Can someone explain me in a bit more detail?
thanks

Phone Myat Kyaw
Ranch Hand
Posts: 31
oh nvm, just my stupid careless mistake.

Because of inheritance, Woop also has Hmpf.

Sorry for my post(happened to be spam)

Lucas Smith
Ranch Hand
Posts: 808
1
Phone Myat Kyaw wrote:Hi, I'm going to sit the SCJP 6.0 exam tomorrow and I'm doing my final preparation. Here's one question make me confusing.

1. class Zing {
2. Hmpf h;
3. }
4. class Woop extends Zing{}
5. class Hmpf { Zing z; }
Which is true? (Choose all that apply.)

Zing has-a Hmpf and Woop is-a Zing.
Hmpf has-a Zing and Woop has-a Hmpf.

I completely understand the first one - Zing class has a Hmpf ref while Woop is inherited from Zing.
But I don't understand why the second answer is correct. What I see is, the first part, Hmpf has-a Zing, is true
but the latter is not. But the mock test I'm taking (from the K&B book) give both are correct.

Can someone explain me in a bit more detail?
thanks

Whoop HAS-A Hmpf brcause it's inherited from Zing.

Just have a look:

Phone Myat Kyaw
Ranch Hand
Posts: 31
Thanks alot Lukas