method overriding with access modifiers in Java


Yes, we can override a method by changing only the access modifiers in java pertaining the following rule:
The access level cannot be more restrictive than the overridden method's access level. For example: If the superclass method is declared public then the overriding method in the subclass cannot be either private or protected.

Updated on: 30-Jul-2019

602 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements