aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes one mock exam question from K&B book Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "one mock exam question from K&B book" Watch "one mock exam question from K&B book" New topic
Author

one mock exam question from K&B book

Phone Myat Kyaw
Ranch Hand

Joined: Dec 26, 2008
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.)

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
Ranch Hand

Joined: Dec 26, 2008
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

Joined: Apr 20, 2009
Posts: 804
    
    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.)

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.

Just have a look:


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
Phone Myat Kyaw
Ranch Hand

Joined: Dec 26, 2008
Posts: 31
Thanks alot Lukas
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: one mock exam question from K&B book