Subclasses and Method Privacy

Java specifies that methods may not be overridden to be more private.

Legal overridden method access


  Private -> Default -> Protected -> Public
  

class BaseClass {
  protected void methodA() {
  }
}

class SubClass extends BaseClass{
  void methodA(){}
}

The output when compiling the code above:


Cannot reduce the visibility of the inherited method from BaseClass
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.