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 Solved by 3 students

Inheritance With Private Methods

Mark
< Prev
Next >

Consider the following class declarations. What is printed as a result of executing the main method?

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

Parent secret
Child secret

B

Compilation Error

C

Child secret

D

Parent secret

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1ahsan4810522 0m 00s 200
#2kwsmith22 0m 00s 200
#3billminhhanguyen22 1m 23s 117
Items per page:
10
1 – 3 of 3

AI Tutor

How can I help?

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