wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Constructors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Constructors" Watch "Constructors" New topic


sridevi chaluvadi

Joined: Mar 23, 2004
Posts: 12
Could you please tell me does constructors get inherited?
thanks in advance
Ray Stojonic
Ranch Hand

Joined: Aug 08, 2003
Posts: 326
They do not
Kaustubh Patil
Ranch Hand

Joined: Aug 13, 2001
Posts: 164
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. Mumbai, India.
sridevi chaluvadi

Joined: Mar 23, 2004
Posts: 12
Thanks Ray and Kaustubh
Consider Paul's rocket mass heater.
subject: Constructors
Similar Threads
Constructors are not inhertied - True
Can constructor throw exception?
Why I can't call the parent class constructor?
another question on constructors
OOP 4: Lookup