class A {
// Identical to "private" alone:
private final void f() {
System.out.println("WithFinals.f()");
}
// Also automatically "final":
private void g() {
System.out.println("WithFinals.g()");
}
}
class B extends A {
private final void f() {
System.out.println("OverridingPrivate.f()");
}
private void g() {
System.out.println("OverridingPrivate.g()");
}
}
class C extends B {
public final void f() {
System.out.println("OverridingPrivate2.f()");
}
public void g() {
System.out.println("OverridingPrivate2.g()");
}
}
public class MainClass {
public static void main(String[] args) {
C op2 = new C();
op2.f();
op2.g();
B op = op2;
// op.f();
// op.g();
A wf = op2;
// wf.f();
// wf.g();
}
}
|