File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes problem #13, p.168 of Sierra and Bates 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 "problem #13, p.168 of Sierra and Bates book" Watch "problem #13, p.168 of Sierra and Bates book" New topic
Author

problem #13, p.168 of Sierra and Bates book

Rachel Glenn
Ranch Hand

Joined: Oct 24, 2012
Posts: 95
The base class Mammal has a String variable called name.
The subclass, Zebra, also has a variable called name.

Why does this compile? What am I missing? Doesn't Zebra inherit the superclass member variables?

Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

R Gle wrote:The base class Mammal has a String variable called name.
The subclass, Zebra, also has a variable called name.

Why does this compile? What am I missing? Doesn't Zebra inherit the superclass member variables?



It is called hiding.if you want to use superclass's name in subclass then write super.name in subclass.


OCA7
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem #13, p.168 of Sierra and Bates book