The following program fails:
abstract class A {
protected void method() {}
}
class B extends A {
private void method() {}
}
public class main{
public static void main(String []args) {}
}
with:
main.java:6: error: method() in B cannot override method() in A
private void method() {}
^
attempting to assign weaker access privileges; was protected
1 error
Setting the derived method to protected/private works.
Question: What is the reason Java won't let you further restrict access in subclasses? I contrast this to C++ which has the exact opposite rule.