File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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
I agree. Here's the link:
subject: Constructors
It's not a secret anymore!