Why default constructor is required(explicitly) in a parent class if it has an argumented constructor
class A {
A(int i){
}
}
class B extends
Assuming that you meant to write class B extends A
:
Every constructor has to call a superclass constructor; if it does not the parameterless superclass constructor is called implicitly.
If (and only if) a class declares no constructor, the Java compiler gives it a default constructor which takes no parameters and calls the parameterless constructor of the superclass. In your example, A
declares a constructor and therefor does not have such a default constructor. Class B
does not declare a constructor, but cannot get a default constructor because its superclass does not have a parameterless constructor to call. Since a class must always have a constructor, this is a compiler error.