permaculture playing cards*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Inherited constructores 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 » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Inherited constructores" Watch "Inherited constructores" New topic
Author

Inherited constructores

Ilan Caspi
Greenhorn

Joined: Aug 21, 2002
Posts: 12
public class base{
public base(){
///What ever
}
}
public class sub extend base{
public sub(){
///What ever
}
}
}
Is the call sub s=new sub(); call base class constructor even though there is no use in super()?
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
First, constructors are not inherited.
Then, even if you do not explicitely invoke super(), the compiler adds it for you.


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Barkat Mardhani
Ranch Hand

Joined: Aug 05, 2002
Posts: 787
As long as default constructor ( Base() ) is not
replaced with an over-loaded construct (e.g
Base(String s). In that case, you have to
explicitly call base constructor from sub
constructor.
Thanks
Barkat
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Inherited constructores
 
Similar Threads
private constructors
Constructor initialization
Subclasses
Dynamic Method Lookup?