hi,
Every constructor(argument or no argument) the first line is super().so it calls the no arg constructor of the super class.
read the following code.
class Super
{
Super(int a){
System.out.println(a);//1st call goes here and prints 3.
}
Super(){
System.out.println("default Super");
}
}
class Sub extends Super{
Sub (int w) //2nd call come here,but here 1st line is implicitly super().
{
//super(); //it calls the no argument constructor of the super class.
System.out.println("Sub w");
}
Sub() //3rd call come here,here the 1st line is implicitly super
{
//super(); //it calls no argument constructor of the super class.
System.out.println("Sub default");
}
public static void main(String args[]){
Super t=new Super(3);//1st call
Sub t1=new Sub(5);//2nd call
Sub t2=new Sub();
}
}
the o/p:
3
default Super
Sub w
default Super
Sub default
with regards,
P.Ramu
SCJP 1.4