Enter your E-mail Address below for Free E-mail Alerts right Into your Inbox: -

Sunday

Difference between method overloading and method overriding in Java

Difference between method overloading and method overriding in Java

This is one of the important tricky programming interview questions asked in Java. Here are the basic differences between method overloading and method overriding in Java.


  1. Method Overloading occurs while compile time and Method Overriding occurs while runtime.
  2. Method Overloading occurs in same class and sub class, but overriding occurs only in subclass.
  3. Static methods can be overloaded, but you can't override static methods.
  4. For overloading method signature has to be changed, but for overriding it's not needed.
  5. Private and final methods can be overloaded but cannot override.

No comments:

Post a Comment