Inheritance and Method Calls
Consider the following class definitions.
public class ClassA {
public void methodA() {
/* implementation not shown */
}
// Other methods are not shown.
}
public class ClassB extends ClassA {
public void methodB() {
/* implementation not shown */
}
// Other methods are not shown.
}
In a client class, the following declarations are made. Assume that ClassA and ClassB each have a no-argument constructor.
ClassA c1 = new ClassA();
ClassA c2 = new ClassB();
Which of the following method calls will result in a compile-time error?
I. c1.methodB();
II. c2.methodB();
III. c2.methodA();
A
I only
B
None of the above
C
III only
D
I and II only
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | sgarv2513 | 1 | 1 | 0m 00s | 100 |
| #2 | kaisuki | 1 | 2 | 0m 00s | 90 |
| #3 | bommasam000 | 1 | 1 | 5m 00s | -200 |
| #4 | y.seong2027 | 1 | 2 | 30m 33s | -1,743 |
Items per page:
10
1 – 4 of 4
APFIVE