Inheritance and Method Call Errors
Given the following class definitions:
public class SuperClass {
// default constructor not shown ...
public void methodX() {
/* implementation of methodX */
}
public void methodY() {
/* implementation of methodY */
}
}
public class SubClass extends SuperClass {
// default constructor not shown ...
public void methodX() {
/* different implementation from methodX in SuperClass */
}
public void methodZ() {
/* implementation of methodZ */
}
}
Assume that the following declarations are made in a client class:
SuperClass s1 = new SuperClass();
SuperClass s2 = new SubClass();
SubClass s3 = new SubClass();
Which of the following method calls will cause a compile-time error?
I. s1.methodZ();
II. s2.methodZ();
III. s3.methodY();
A
I and II only
B
I only
C
I, II, and III
D
II only
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | kaisuki | 1 | 1 | 0m 00s | 100 |
| #2 | psak12 | 1 | 1 | 3m 09s | -89 |
| #3 | y.seong2027 | 0 | 1 | 1m 44s | -114 |
| #4 | suhanakochhar006 | 1 | 2 | 17m 28s | -958 |
Items per page:
10
1 – 4 of 4
APFIVE