| 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 Instance Method
< Prev
Next >

What happens when the main() method is executed?

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

class Child extends Parent {
    public static void display() {
        System.out.print("Child ");
    }
    
    public static void main(String[] args) {
        Parent p = new Child();
        p.display();
    }
}
A

No output

B

Parent Child

C

Compilation Error due to static method hiding an instance method

D

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.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy