Page 1 of 1

About Question com.enthuware.ets.scjp.v6.2.531 :

Posted: Fri Jul 31, 2015 12:52 am
by desertrat

Code: Select all

class A
{
  public A() {} // A1
  public A(String s) {  this();  System.out.println("A :"+s);  }  // A2
}
class B extends A
{
  public int B(String s) {  System.out.println("B :"+s);  return 0; } // B1
}
class C extends B
{
    private C(){ super(); } // C1
    public C(String s){  this();  System.out.println("C :"+s);  } // C2
    public C(int i){} // C3
}
How can this code compile when Class B does not have a no arg constructor and super() is called from C in the constructor?

edit: n/m I missed that there is only a method claimed in class B (not a constructor). Time for bed!