aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question in scjp study guide (Kathey & Bates) page 181- oo Concepts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question in scjp study guide (Kathey & Bates) page 181- oo Concepts" Watch "Question in scjp study guide (Kathey & Bates) page 181- oo Concepts" New topic
Author

Question in scjp study guide (Kathey & Bates) page 181- oo Concepts

thejaka samarakoon
Ranch Hand

Joined: Jul 20, 2010
Posts: 56


In this question Why the out put display as
furry bray?
How that the m.makeNoise()output not becomes "generic noise"?
Ikpefua Jacob-Obinyan
Ranch Hand

Joined: Aug 31, 2010
Posts: 394

thejaka wrote:How that the m.makeNoise()output not becomes "generic noise"?

Hello thejaka,
polymorphism is ONLY for instance methods. At runtime it is the 'overriding' method in the object's 'TYPE' that is invoked. In line 12 of the program: the object's 'TYPE' is Zebra, hence the overriding makeNoise() method in the class Zebra is invoked.

I hope this helps.

Regards

Ikpefua


OCPJP 6.
In Your Pursuit Towards Certification, NEVER Give Up.
thejaka samarakoon
Ranch Hand

Joined: Jul 20, 2010
Posts: 56
Thanks.
shalindra Singh Suryvanshee
Greenhorn

Joined: Aug 05, 2008
Posts: 25


now if you say - it will pick the instance variable value from Mammal class (since name variable do not get overridden).
but when you write - it will display the output from the method, object does belong to. here in this case it is from Zebra class. (method is overridden in Zebra class).

Thanks
Shalindra


Regards
Shalindra Singh
SCJP, SCWCD
 
wood burning stoves
 
subject: Question in scjp study guide (Kathey & Bates) page 181- oo Concepts