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: 2020-02-24T06:03:42+05:30

6K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements