Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
medium Solved by 4 students

Inheritance and Method Call Errors

< Prev
Next >

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, II, and III

C

II only

D

I only

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question
Mark for review

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1kaisuki11 0m 00s 100
#2psak1211 3m 09s -89
#3y.seong202701 1m 44s -114
#4suhanakochhar00612 17m 28s -958
Items per page:
10
1 – 4 of 4
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|FAQ