Valid Method Calls with Inheritance
Consider the following class definitions.
public class Parent {
// constructor not shown
public void funA() {
/* implementation */
}
public void funB() {
/* implementation */
}
}
public class Child extends Parent {
// constructor not shown
public void funA() {
/* different implementation */
}
public void funC() {
/* implementation */
}
}
Assume the following declarations have been made in a client class.
Parent p1 = new Parent();
Parent p2 = new Child();
Child p3 = new Child();
Which of the following method calls will compile without error?
I. p1.funC();
II. p2.funC();
III. p3.funB();
A
III only
B
I and II only
C
II only
D
I only
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE