| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice TestPractice Test
About Exam
hard
Superclass Method Call and Variable Shadowing
< Prev
Next >

Consider the following class declarations. What is printed when the main method in the Derived class is executed?

class Base {
    int num = 3;
    String getInfo() { return "Base" + num; }
}

class Derived extends Base {
    int num = 7;
    String getInfo() { return super.getInfo() + (num * 2); }
    public static void main(String[] args) {
        Derived d = new Derived();
        System.out.println(d.getInfo());
    }
}
A

Base314

B

Compilation Error

C

Base37

D

Base3 14

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

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