aspose file tools*
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
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: 417
Leandro Coutinho
Ranch Hand

Joined: Mar 04, 2009
Posts: 417
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: 18978
    
  40

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?