posted 23 years ago
Hi,
To clarify your doubt, lemme cut-paste a clause from JLS that explains clearly what happens:
"If a constructor body does not begin with an explicit constructor invocation and the constructor being declared is not part of the primordial class Object, then the constructor body is implicitly assumed by the compiler to begin with a superclass constructor invocation "super();", an invocation of the constructor of its direct superclass that takes no arguments."
So, in your code,
class B(int w)
{
//super(); This is included automatically!
...
}
Since you have provided a constructor for A, the default constructor for A is not considered and hence the error! To rectify this, either include a default constructor for A of type
A()
{}
or
in your class B constructor, include a line to say,
B(int w)
{
super(w);
...
}
Then, it would work fine.
Aparna