class Test2{ public Test2(int i){ System.out.println(i); } } class Test3 extends
ID: 669825 • Letter: C
Question
class Test2{ public Test2(int i){ System.out.println(i); } }
class Test3 extends Test2{
}
This is a test review slide.. it asks is how you would fix this? I'm curious what's wrong with it? Thanks!!..
class Test2{ public Test2(int i){ System.out.println(i); } }
class Test3 extends Test2{
}
This is a test review slide.. it asks is how you would fix this? I'm curious what's wrong with it? Thanks!!..
class Test2{ public Test2(int i){ System.out.println(i); } }
class Test3 extends Test2{
}
This is a test review slide.. it asks is how you would fix this? I'm curious what's wrong with it? Thanks!!..
Explanation / Answer
The error is:
The class Test3 extends class Test2 but it the super class constructor Test2() is undefined in the base class and the base class doesn't have any constructor having 1exactly 1 int parameter.
It can be corrected by changing Test3 to:
class Test3 extends Test2{
public Test3(int i) {
super(i);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.