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 Binding of Private Methods

Mark
< Prev
Next >

Consider the following code segment.

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

class B extends A {
  private void secret() {
    System.out.println("B secret");
  }
}

public class Main {
  public static void main(String[] args) {
    A obj = new B();
    obj.reveal();
  }
}

What is printed as a result of executing the code?

A

Compilation Error

B

A secret

C

A secret
B secret

D

B 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.

AI Tutor

How can I help?

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