Difference Between Overloading and Overriding

In high-level languages, many coding techniques are implemented by coders to make the code more legible and simple. Moreover, many functions and constructors are also made in the program.


IT Quiz

Test your knowledge about topics related to technology

1 / 10

Artificial Intelligence is a way of _____.

2 / 10

What does AM mean?

3 / 10

Which two websites offer free e-mail services?

4 / 10

For which of the following Android is mainly developed?

5 / 10

WWW Stands for

6 / 10

Which number system has a base 16

7 / 10

Saving a file from the Internet onto your desktop is called

8 / 10

Which American Computer Company is also known by the nick name "Big Blue"

9 / 10

What was the name of the space shuttle that landed man on the moon?

10 / 10

Which of the following AI domain attempts to extract information from spoken and written words using algorithms?

Your score is


Such functions and constructors can be overloaded by different parameters or overridden. Let’s understand this in detail.

Overloading and overriding are two programming techniques used by programmers when writing code in high-level languages like C++, Java, Python, and others. Both strategies are effective in making the software less difficult.

The overloading function is used to make the code more readable. However, the overriding method overwrites the parent class.

Key Takeaways

  1. Overloading occurs when multiple methods with the same name but different parameters exist in a class. At the same time, overriding happens when a subclass provides a new implementation for a method defined in its superclass.
  2. Overloading enables method functionality to vary based on input parameters, whereas overriding allows a subclass to modify or extend the behavior of a superclass method.
  3. Overloading is resolved at compile time while overriding is determined at runtime.

Overloading vs Overriding

Overloading is an object-oriented programming feature that allows many methods with the same name but distinct parameters to exist. Overriding is the process of supplying a new implementation for a method in a subclass that already exists in the superclass.

Overloading vs Overriding

Want to save this article for later? Click the heart in the bottom right corner to save to your own articles box!

Overloading entails writing the same functions many times with different parameters. However, we can’t do this in the C programming language. Otherwise, Java supports the concept of overloading.

Three types of overloading can be done by programmers while coding in Java. It is a useful concept to make the program simple.

In computer language, an overriding method is utilized in the concept of inheritance. Whenever a function is created in the superclass and then used in a subclass by inheriting the main class’s methods.

It allows the subclass to override the parent class’s function since the subclass has priority when the program runs.

Comparison Table

Parameters of ComparisonOverloadingOverriding
PurposeTo overload the same function.Using the parent class’ methods to the subclass.
UsedOverloading occurs in the same class or even in different ones too.Overriding is done in separate classes having inheritance relation.
ParametersThe parameters are different from each other.Parameters are the same in both subclass and superclass.
Return TypeUnder overloading, the return type can be either the same or different.Under overriding, the return type should be the same.
PolymorphismSince one function can take distinct parameters in overloading at compile time. So, it is compile-time polymorphism. Overriding is also known as run time polymorphism.

What is Overloading?

Overloading refers to overloading the same method several times. In C language, we can’t overload functions. However, in Java, we can overload in three ways.

The types are construction overloading, method overloading, and operator overloading.

When a programmer reuses the same code, the arguments are changed every time. It is known as underloading.

Default overloading (definition of the same function without any parameters) and parameter overloading (defining a function with parameters) are both possible.

The operator (+) is defined for both addition and concatenation (linking) in the case of operator overloading. Furthermore, the return type of the parameters does not have to be the same.

The process of overloading is known as polymorphism (using the same thing in a separate form while compiling). As a result, it’s referred to as compile-time polymorphism.

Example of a constructor overloading

Class X


Int a;

X (),


a= 10;


X (int x);





Class Y


public static void main (args)


X obj= new X();

X obj1= new X(100);

System.out.println(obj.a” “);

System.out.println(obj1.a” “);



In the above example, constructor X appears twice. There was no argument the first time, and the second time there was a parameter. Distinct objects (obj, obj1 ) exist to tell values.

Similarly, one can use functions and operators in the overloading concept.

What is Overriding?

Under class inheritance, programmers use method overriding (when properties of one class are inherited into another one).

If a subclass or child class is dissatisfied with the execution of the superclass’s or parent’s methods while inheriting, the subclass can override its function.

For overriding, method or function in both, the class should be the same along with the parameters defined. In addition, the return type and scope should be identical in both classes.

However, there are two limitations to overriding. The first is that the coders cannot override a super class’s static function. Another disadvantage is if the function’s type in the main class is declared as final. In a sub-class, it is not possible to override it.

Let’s understand with an example:

Class Super


void show();


system.out.println(” OVERRIDE”);



Class Sub extends Super


void show();


system.out.println(” OVER”);



Class override


public static main (string[], args())


Sub s= new Sub();

s.show ();



The output of the above example will be (OVER). It signifies that only the output of a subclass will appear because subclass (Sub) has overridden superclass (Super).

No results of the main class will be there. Moreover, the function (show) has the same return type, scope, and arguments.

Main Differences Between Overloading and Overriding

  1. Overloading can occur inside a single class or across multiple classes. To override the function, we must create at least two classes.
  2. Overloading is not possible in the C programming language. However, overriding is not feasible when one of the main class’s functions is static or final.
  3. Overloading is also known as compile-time polymorphism. On the other hand, overriding is done at run time (known as run time polymorphism).
  4. The return type can change while the program is being executed with overloading. When employing overriding, however, this is not possible.
  5. Overloading makes the program easy for coders. On the contrary, overriding is done if the coder is not satisfied with the values of the main class.
  1. https://link.springer.com/chapter/10.1007/978-3-642-14107-2_25
  2. https://dl.acm.org/doi/abs/10.1145/1141277.1141608

One request?

I’ve put so much effort writing this blog post to provide value to you. It’ll be very helpful for me, if you consider sharing it on social media or with your friends/family. SHARING IS ♥️

Leave a Comment

Your email address will not be published. Required fields are marked *