Differences between method overloading and method overriding

 Posted by Ddd on 2/7/2011 | Category: .NET Framework Interview questions | Views: 22941 | Points: 40

Method Overloading and Method Overriding are both the techniques used to implement FUNCTIONAL POLYMORPHISM
They enhance the methods functionality using their respective features.

1) It involves having another method with the same name in a class or its derived class.

2)can be implemented with or without inheritance.

3)It is implemented by:

a)changing the number of parameters in different methods with same name.

b)changing the parameter data types (if the number of parameters are same)

c)changing parameter order.

4)applicable to static as well as non static methods:

5)no keywords needed before the method names in C#.

6)also called as COMPILE TIME Polymorphism.
example: int add(int a, int b)
return a+b;
int add(int a)
return a*5;


1) It involves having another method with the same name in a base class and derived class.

2)always needs inheritance.

3)It is implemented by having two methods with same name, same signature, but different implementations (coding)in a base class and derived class

4)applicable to nonstatic, nonprivate methods only.access modifiers of the methods are not changed in the base and derived classes.

5)virtual and override keywords are needed before the method names in base and derived classes.
For overriding in firther classes, override keyword will be used,

6)RUN TIME Polymorphism
class A
public virtual void demo()

class B:A
public override void demo()

static void Main()
B obj=new B();

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response