| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice TestPractice Test
Share
About Exam
medium Solved by 1 students
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

III only

B

I and II only

C

II only

D

I only

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer

Question Leaderboard

Not enough data yet to show leaderboard.

AI Tutor

How can I help?

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