• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inherited constructores

 
Ilan Caspi
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, constructors are not inherited.
Then, even if you do not explicitely invoke super(), the compiler adds it for you.
 
Barkat Mardhani
Ranch Hand
Posts: 787
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic