File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes inheritance issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "inheritance issue" Watch "inheritance issue" New topic
Author

inheritance issue

rakesh kadulkar
Ranch Hand

Joined: Jul 24, 2008
Posts: 115
Hi,
I have a question that whenever I create the object of the derived class the constructor of superclass gets called.
I mean to say a constructor is called only when the object is created does that mean that whenever I create derievd class Object superclass Object also gets created.

Further I want to ask instance method is called only when object exists but I can call the superclass instance method
from the subclass method which I have overridden in subclass. without creating the superclass object.
How?

Thanks.

Rakesh Kadulkar
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

rakesh kankavlikar wrote:
I have a question that whenever I create the object of the derived class the constructor of superclass gets called.
I mean to say a constructor is called only when the object is created does that mean that whenever I create derievd class Object superclass Object also gets created.

Your Sub class Constructor calls "super()"[it calls your Super Classe's default Constructor] in his first line implicitly. please Avoid the term of "derived class " . it is not C++

rakesh kankavlikar wrote:
Further I want to ask instance method is called only when object exists but I can call the superclass instance method
from the subclass method which I have overridden in subclass. without creating the superclass object.
How?


that is what IS-A relationship is
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inheritance issue