posted 19 years ago
Hi Swapnil,
Its like this, if u dont have no args constructor in the supercalss i.e superclass is having all constructors with arguments, then in the constructor of the baseclass we have to give an explicit call to the superclass constructor with apropriate arguments otherwise there will be compile time error that 'there is no such constructor Superclass()']
Look at the example below
class Superclass()
{
Superclass(int a){}
Superclass(float b){}
}
public class Baseclass() extends Superclass
{
Baseclass()
{
/*if we dont inclde line 2 ,then compiler will insert a default call to Superclass construcor here i.e. super() i.e super with no args which is not defined in superclass ,hence it will give compile time error*/
super(10); //(2)
}
I hope this will help u.
Thanks,<br />Swati Thorve<br />SCJP 1.4