| preferred AP College board partner for AP classes
AP Computer Science A/Unit 5: Writing Classes
Start Practice TestPractice Test
Share
About Exam
medium Solved by 4 students
Inheritance and Method Calls
< Prev
Next >

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

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1sgarv251311 0m 00s 100
#2kaisuki12 0m 00s 90
#3bommasam00011 5m 00s -200
#4y.seong202712 30m 33s -1,743
Items per page:
10
1 – 4 of 4

AI Tutor

How can I help?

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