thanks for the explanation but how do you explain this output
class Base{
public Base() {
System.out.println("base default constructor");
}
public Base(int i) {
System.out.println("base constructor:"+i);
}
}
class Derived extends Base{
Derived()
{
this((int)9);
System.out.println("derived default constructor");
}
Derived(int j)
{
super(j);
System.out.println("derived constructor"+j);
}
}
public class
test {
public static void main(
String args[])
{
Derived obj=new Derived();
}
}
output:
base constructor:9
derived constructor9
derived default constructor
shouldn't the base class default constructor be called here again in the default derived class constructor??
then ideally the oupt should have been :
base default constructor
base constructor:9
derived constructor9
dervived default constructor