Hello all,
Suppose we have a super class and a sub class extended from it.
Have a look at this code:
class constrDemo
{
public static void main(
String args[])
{
}//end main()
}//end class definition
class superClass
{
int x;
superClass(int x)
{
this.x = x;
}
superClass(int x,int y)
{
}
superClass()
{
}
}//end class superClass
class subClass extends superClass
{
subClass(int x)
{
super(x);//line 1
}//end constructor
subClass(int x,int y)
{
super(x,y);//line 2
}
}//end class SubClass
In the above code in Superclass If i remove "no arg" constructor and comment Line 1 and Line 2,Iam getting error.
If I put no arg constructor in Super class and comment these lines, code is compiling fine.
My doubt is
In super class if there is no "no-arg" constructor then in subclass construtors
we must call subclass' couter part of constructor in super class(if their access permits)?