Difference WikiTechnology

Difference Between Overriding and Overloading

Main Difference

Overriding and Overloading are not those terms, which you thinks associated with heavy vehicle transportation. A software developer or a programmer knows what are the meaning of these terms for them. Overriding and Overloading are basically related with Java, C++ and others programming languages. These features are used to gives different meaning to different context in a programming. Below is the detail of both terms and their differences.

What is Overriding?

Overriding is the feature in programming language, which is used to associate same methods names with same signatures. In this system, a programmer gives a specific implementation method to subclass or child class, which is already provided by him to a parent class or super class. It works in two direction, either in parent class or in child class. For example if some changes are executed in parent class then it will be also accepted by the child class and vice versa. There is also an option to prevent the method of Overriding by the programmer.

ADVERTISEMENT

What is Overloading?

Overloading is a function in program languages, which associates multiple same name to an object with different implementations. It is basically used by those operators, who behave differently in case of change in data type, class and operands. Among multiple programming languages, only C++ and Java supports the Overloading. Function name and operator overloading are two different kinds of Overloading. Overloading is implemented at the compile time on the specific class and mostly static methods allows the overloading.

Key Differences

  1. First there is timing of implementation. Overloading is implemented at compile time while Overriding is implemented at runtime.
  2. Static methods can be overload but cannot be override. Because a class or object can have more than one static method with the same name, which is possible in overload not in override.
  3. Overloading is associated with giving implementation to specific class so it can be done in the same class while Overriding requires both parent and child class for implementation.
  4. Static binding is used in case of Overloading while for Overriding dynamic binding is used.
  5. Overloading provides better performance because it is done at runtime, which is not available in case of Overriding.
  6. Same data type is required in case of Overriding method while there is choice for the same in case of Overriding.
  7. Overriding is used in Ada, C#, C++, Delphi, Eiffel, Java and Python while usually C++ and Java allows the Overloading.
ADVERTISEMENT

Comparison Video

YouTube video
Harlon Moss

Harlon currently works as a quality moderator and content writer for Difference Wiki. He graduated from the University of California in 2010 with a degree in Computer Science. Follow him on Twitter @HarlonMoss