When a message can be processed in different ways is called polymorphism. Polymorphism means many forms.  Polymorphism is one of the fundamental concepts of OOP.

Polymorphism provides following features:
·   It allows you to invoke method of derived class through base class
reference during runtime.
·   It has the ability for classes to provide different implementations of
methods that are through the same name.
Polymorphism is of two types:

(1)    Compile Time polymorphism /Overloading

(2)    Runtime Polymorphism/ Overriding

Compile Time polymorphism:

Compile Time polymorphism is method and operators overloading. It is also called early binding.

In method overloading method performs the different task at the different input parameters.

Compile Time polymorphism:

Compile Time polymorphism is done using inheritance and virtual functions. Method overriding is called runtime polymorphism. It is also called binding.

When overriding a method, you can change the behavior of the method for the derived class. Overloading a method simply involves having another method with same prototype.

Public class print
Public void display(string name)
Console.WriteLine(“Your name is :” +name);
Public void display(int age, flot markes)
Console.WriteLine(“Your age is :” +age);
Console.WriteLine(“Your mark is :” +marks);
Static void main()
Print  obj=new print();
Obj.display(“Mind Stick”);

 You can also read these related post




  Modified On Sep-18-2014 01:23:52 PM

Leave Comment