Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice TestPractice Test
About Exam
medium

Valid Method Calls with Inheritance

< Prev
Next >

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

I and II only

B

III only

C

I only

D

II only

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

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

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