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 C can't extend one class (B) and implement an interface (1A), it can only do one or the other. No, Class C doesn't correctly override do_stuff2() No, class C cannot be instantiated because it implements an interface. 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!