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
hard

Static Method Hiding in Inheritance

Mark
< Prev
Next >

What is printed as a result of executing the following code segment?

public class Parent {
    public static void display() { System.out.println("Parent"); }
}

public class Child extends Parent {
    public static void display() { System.out.println("Child"); }
}

public class Main {
    public static void main(String[] args) {
        Parent p = new Child();
        p.display();
    }
}
A

Parent

B

Child

C

Compilation Error

D

Parent and Child

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.

AI Tutor

How can I help?

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