This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.

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.)

Answers are
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 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.)

Answers are
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.