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

Child

B

Parent and Child

C

Parent

D

Compilation Error

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: [email protected]|Privacy Policy