This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Inheritance: what's the output? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Inheritance: what Watch "Inheritance: what New topic
Author

Inheritance: what's the output?

Leandro Coutinho
Ranch Hand

Joined: Mar 04, 2009
Posts: 423
Leandro Coutinho
Ranch Hand

Joined: Mar 04, 2009
Posts: 423
I got surprised with the result. I thought instances of the super classes were always created before the child classes, but, based on the result, it seems that it is not what happen.
It's more like the not private members of the super class are included inside the child class, and you can use "super" and "this" more like a namespace ...
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19926
    
  43

Leandro Coutinho wrote:I got surprised with the result. I thought instances of the super classes were always created before the child classes, but, based on the result, it seems that it is not what happen.
It's more like the not private members of the super class are included inside the child class, and you can use "super" and "this" more like a namespace ...


Well... yeah. That's how it works. When you create an instance (with the new operator), there is only one instance. Large inheritance trees don't generate lots of objects..... And the private members of the super class are included too.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inheritance: what's the output?
 
It's not a secret anymore!