What is method overriding?



Method overriding occurs when sub class declares a method that has the same type arguments as a method declared by one of its superclass. The key benefit of overriding is the ability to define behavior that’s specific to a particular subclass type.
Note:

  • The overriding method cannot have a more restrictive access modifier than the method being overridden (Ex: You can’t override a method marked public and make it protected).

    • You cannot override a method marked final
    • You cannot override a method marked static


    Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

    Make sure to activate your subscription by clicking on the activation link sent to your email