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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!