Difference between an abstract method & virtual method
Ranjithkumar Murugesan
Select an image from your device to upload
Virtual method has an implementation & provide the derived class with the option of overriding it. Abstract method does not provide an implementation & forces the derived class to override the method. important Notes: (a)Any Class with abstract method or property in it must be declared abstract (b)Attempting to instantiate an object of an abstract class retults in a compilation error Example:
Shape m_MyShape = new Shape(); //it is Wrong to that.
But we can do that.
Shape m_MyShape = new Circle(); // True
Or
Shape m_MyShape;
/*
declare refrences only, and the refrences can refer to intances of
any concrete classes derived from abstract class
*/
Circle m_MyCircle = new Circle();
m_MyShape = m_MyCircle; // Also True