| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice TestPractice Test
About Exam
hard Solved by 3 students
Inheritance With Private Methods
< Prev
Next >

What is the output when the main() method is executed?

public class Parent {
    private void secret() {
        System.out.println("Parent secret");
    }
    public void reveal() {
        secret();
    }
}

public class Child extends Parent {
    private void secret() {
        System.out.println("Child secret");
    }
}
public class Main {
    public static void main(String[] args) {
        Parent p = new Child();
        p.reveal();
    }
}
A

Child secret

B

Compilation Error

C

Parent secret

D

Parent secret
Child secret

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