java access modifiers with method overriding

Yes, an overridden method can have a different access modifier but it cannot lower the access scope.

The following rules for inherited methods are enforced -

  • Methods declared public in a superclass also must be public in all subclasses.
  • Methods declared protected in a superclass must either be protected or public in subclasses; they cannot be private.
  • Methods declared private are not inherited at all, so there is no rule for them.

Updated on: 24-Feb-2020

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started