Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Constructors

 
sridevi chaluvadi
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Could you please tell me does constructors get inherited?
thanks in advance
sridevi
 
Ray Stojonic
Ranch Hand
Posts: 326
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They do not
 
Kaustubh Patil
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well. This is partly correct.
If you do not call the parent class constructor explicitly java automatically calls the 'no argument' constructor of the parent class, if the parent class has one. This is done in the begining of the child constructor.
If you want to call the constructor with some argument(s), then it has to be done explicitly, using super(). And should be the first statement in the child constructor.
Hope this helps.
Kaustubh.
 
sridevi chaluvadi
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ray and Kaustubh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic