Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

inheritance issue  RSS feed

 
rakesh kadulkar
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!