Pages

Men

rh

7/01/2012

Dynamic or Runtime Polymorphism.

Dynamic or Runtime Polymorphism.
  •  Run time polymorphism is also known as method overriding. 
  •   In this mechanism by which a call to an overridden function is resolved at a Run-Time (not at Compile-time)base Class contains a method that is overridden. 
  • Method overriding means having two or more methods with the same name, same signature but with different implementation.  
             In this process, an overridden method is called through the reference variable of a super class the determination of the method to be called is based on the object being referred to by reference variable.

Example
Class BaseClass
{
Public void show ()
{
Console.WriteLine("From base class show method");
}

}
Public Class DynamicDemo : BaseClass
{
Public void show()
{
Console.WriteLine("From Derived Class show method");
}
Public static void main(String args[])
{
DynamicDemo dpd=new DynamicDemo ();
Dpd.show();

}
}

No comments :

Post a Comment