Easy learning with example program codes

difference between method overloading and overriding in java?

Method overloading

Method overloading is the way of implementing static/compile time polymorphism in java. Method overloading means more than one methods in a class with same name but different parameters. Parameters can be differing in types, numbers or order. Compiler resolve method call by matching method signature at compile time, that’s why it is known as static or compile time polymorphism. It is also known as static binding.

Ways to implement method overloading in java:

  1. Parameters differ in types.
  2. Parameters differ in number.
  3. Parameters differ in order.


Method overriding

If a subclass provides a method with the same signature (name and parameter) as in its super class, then subclass overrides the method of its super class. This process of overriding a super class method by subclass is known as method overriding.

Conditions for method overriding:

  1. Method in subclass must have same signature as in its super class.
  2. Two classes must follow IS-A relationship.


Method OverloadingMethod Overriding
Method overloading increases the readability of the program.Method overriding provides the specific implementation of the method that is already provided by its super class.
Method overloading is occurs within the class.Method overriding occurs in two classes that have IS-A relationship.
 Parameter must be different.Parameter must be same.


Java interview questions on method overloading and overriding

Please follow and like us:

Copyright © 2020 CodesJava Protection Status