hi,
When I tried to run the below program. I got the error as
ConstructorTest.java:18: cannot resolve symbol
symbol : method SuperConstrctr (int,int)
location: class SubConstrctr
SuperConstrctr(i,j);
^
1 error
but in the rules of constructor, I read that
==========================================================================
A call to super() can be either a no-arg call or can include arguments passed to the super constructor.
==========================================================================
Can somebody help to figure out the problem with the below program.
class SuperConstrctr
{
int k,l;
SuperConstrctr() {
System.out.println("No arg super constructor");
}
SuperConstrctr(int i,int j) {
this.k = i;
this.l = j;
System.out.println("Super arg Constructor");
}
};
class SubConstrctr extends SuperConstrctr
{
int i,j;
SubConstrctr(int i,int j) {
SuperConstrctr(i,j);
this.i = i;
this.j = j;
System.out.println("Subclass Constructor");
}
};
public class ConstructorTest
{
public static void main(String[] args)
{
SubConstrctr constrctr = new SubConstrctr(30,20);
}
}
Thank You.
When I tried to run the below program. I got the error as
ConstructorTest.java:18: cannot resolve symbol
symbol : method SuperConstrctr (int,int)
location: class SubConstrctr
SuperConstrctr(i,j);
^
1 error
but in the rules of constructor, I read that
==========================================================================
A call to super() can be either a no-arg call or can include arguments passed to the super constructor.
==========================================================================
Can somebody help to figure out the problem with the below program.
class SuperConstrctr
{
int k,l;
SuperConstrctr() {
System.out.println("No arg super constructor");
}
SuperConstrctr(int i,int j) {
this.k = i;
this.l = j;
System.out.println("Super arg Constructor");
}
};
class SubConstrctr extends SuperConstrctr
{
int i,j;
SubConstrctr(int i,int j) {
SuperConstrctr(i,j);
this.i = i;
this.j = j;
System.out.println("Subclass Constructor");
}
};
public class ConstructorTest
{
public static void main(String[] args)
{
SubConstrctr constrctr = new SubConstrctr(30,20);
}
}
Thank You.