Meaningless Drivel is fun!*
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Constructors" Watch "Constructors" New topic
Author

Constructors

sridevi chaluvadi
Greenhorn

Joined: Mar 23, 2004
Posts: 12
Hi,
Could you please tell me does constructors get inherited?
thanks in advance
sridevi
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.


Kaustubh. Mumbai, India.
sridevi chaluvadi
Greenhorn

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