Given:
public class Main extends MyClass { public static void main(String[] args) { try {//from w w w . jav a 2 s . c o m new Main().do1(); new Main().do2(); new Main().do3(); } catch (Throwable t) { System.out.print("exc "); } } } class MyClass { void do1() { System.out.print("do1 "); } private void do2() { System.out.print("do2 "); } protected void do3() { System.out.print("do3 "); } }
What is the result?
D is correct.
Even a subclass can't access a superclass's private method.