Hi All,
can anyone tell how the hierarchy of constructors are fired.
class A{
A(){}
A(int i){
this();
System.out.println(" int A");
}
}
class B extends A{
public boolean B(
String s) {
System.out.println("B string");
return false ;
}
}
class
Test extends B{
private Test(){
super();
System.out.println("test");
}
public Test(String a){this() ;
System.out.println("string test");
}
public Test(int i){
System.out.println("int test");
}
public static void main(String args[]){
new Test(3) ; // here
}
}
at the commented line .... I think the compiler should give an error telling that the parent B has no constructor with an int.... or there is no default constructor ...mean B(). but this does'nt happen...the code compiles fine.
Can anyone explain.
Thx in advance