• Business
  • Finance
  • Banking
  • Education
  • General
  • Law
  • Science
  • IT
  • English

Key Differences

Know the Differences & Comparisons

Difference Between Method Overloading and Overriding

Last updated on June 8, 2019 by Surbhi S

method overloading vs method overridingMethod Overloading

Method overloading, also known as Function overloading or Compile time polymorphism, is a concept of having two or more methods with the same name but different signature in the same scope. There are many programming languages that support this feature: Ada, C++, C#, D, and Java.

Example of Method Overloading in C#
overloadingAs shown in the above example, the method ‘Polygon’ is overloaded 3 times with different method signature, i.e the type or the number of parameters are different.

Method Overriding

Method overriding, also known as Function overriding or Run time polymorphism, is an OOP feature that allows a child class to provide its own implementation to the method defined in the parent class. The implementation in the child class overrides the definition of the method in the base class, provided that the method in the child class should have the same name, signature and return type.

Example of Method Overriding in C#
overridingHere, the draw method in the Source2 class overrides the draw method defined in the Source1 class.

Difference Between Method Overloading and Method Overriding

  1. In Method overloading methods must have a different signature. In method, overriding methods must have the same signature.
  2. Function Overloading is to “add” or “extend” more to method’s behaviour. Function overriding is to completely “change” or “redefine” the behaviour of a method.
  3. Method overloading is used to achieve Compile time polymorphism; method overriding is used to achieve run-time polymorphism.
  4. In method/function overloading compiler knows which object assigned to which class at the time of compilation, but in method overriding this information is not known till runtime.
  5. Function Overloading takes place in the same class whereas Overriding takes place in a class derived from a base class.

Related Differences

  • Difference Between Himalayan and Peninsular Rivers
  • Difference Between NBFC and Bank
  • Difference Between Wholesaler and Distributor
  • Difference Between Scalar and Vector Quantity
  • Difference Between Ordinary Annuity and Annuity Due

You Might Also Like:

abstract class vs interfaceDifference Between Abstract class and Interface in C# Difference Between Interface and Class Pooling of Interest Vs Purchase MethodDifference Between Pooling of Interest Method and Purchase Method ref vs out parameterDifference Between ref and out parameter in c# research method vs methodologyDifference Between Research Method and Research Methodology childish-vs-childlikeDifference Between Childish and Childlike

Comments

  1. karamath sheik says

    February 4, 2016 at 3:11 pm

    Thanks for choosing this post to write it thanks one again…

    Reply

Leave a Reply Cancel reply

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

Top 5 Differences

  • Difference Between PERT and CPM
  • Difference Between Micro and Macro Economics
  • Difference Between Developed Countries and Developing Countries
  • Difference Between Management and Administration
  • Difference Between Qualitative and Quantitative Research

Related Differences

  • Difference Between Himalayan and Peninsular Rivers
  • Difference Between NBFC and Bank
  • Difference Between Wholesaler and Distributor
  • Difference Between Scalar and Vector Quantity
  • Difference Between Ordinary Annuity and Annuity Due



New Additions

  • Difference Between Budget Line and Budget Set
  • Difference Between Active and Passive Learning
  • Difference Between Active Listening and Passive Listening
  • Difference Between Traditional Marketing and Digital Marketing
  • Difference Between Primary Group and Secondary Group
  • Difference Between Real Flow and Money Flow
  • Difference Between Stock and Flow
  • Difference Between Single Use Plan and Standing Plan
  • Difference Between Autonomous Investment and Induced Investment
  • Difference Between Packaging and Labelling

Copyright © 2021 · Key Differences · Contact Us · About Us · Privacy