Question: Will the following code compile? abstract class A { public int do_stuff1() { return 3; } } class B extends A { @Override public int

Will the following code compile?
abstract class A {
public int do_stuff1() {
return 3;
}
}
class B extends A {
@Override
public int do_stuff1() {
return 4;
}
public int do_stuff2() {
return 7;
}
}
class Main {
public static void main(String[] args) {
//Note the polymorphism:
A myB = new B();
myB.do_stuff1();
myB.do_stuff2();
}
}
No, class A is marked abstract, but has no abstract methods, and that is not allowed. No, class A has no do_stuff2() therefore you can't call do_stuff20 on myB in main. No, class A is abstract, so you can't call do_stuff10 even though there is an override in class B. Yes
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
