In class B, there are three constructor. Those constructor doesn't call explicitly any constructor of its super class. In that case default constructor of super class i.e "A()" would be called. So, in all three cases default constructor of super class i.e A() is getting called.
Calling the constructor of base class explicitly, otherwise default constructor is called.
public class A {
int a;
A(){
System.out.println("A()");
}
A(int i){
System.out.println("A(int)");
}
A(int i,int j){
System.out.println("A(int,int)");
}
}
public class B extends A{
int b;
B(){
super();
System.out.println("B()");
}
B(int i){
super(i);
System.out.println("B(int)");
}
B(int i,int j){
super(i,j);
System.out.println("B(int,int)");
}
}
public class Demo {
public static void main(String args[]){
B b1=new B();
B b2=new B(100);
B b3=new B(100,200);
}
}
She still doesn't approve of my superhero lifestyle. Or this shameless plug:
a bit of art, as a gift, the permaculture playing cards