Question: Assume classes Based, Derived, and Test are defined as indicated below. What happens when we compile and run Test? public class Base { public void
Assume classes Based, Derived, and Test are defined as indicated below. What happens when we compile and run Test?
public class Base { public void f() { System.out.println("Base.f()"); } } public class Derived extends Base { public void f() { System.out.println("Derived.f()"); } } public class Test { public static void main(String[] args) { Base b = new Derived(); b.f(); } } Question 3 options:
|
| An error occurs when we try to compile |
|
| Base.f() is displayed to the screen |
|
| Derived.f() is displayed to the screen |
|
| An exception is thrown when we try to execute Test. |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
