Abstract Class :
-          An abstract class means that, no object of this class can be instantiated, but can make derivations of this.
-          An abstract class can contain either abstract methods or non abstract methods.
-          An abstract class cannot be a sealed class. I.e. the following declaration is incorrect.
-          An abstract method cannot be private.
-          The access modifier of the abstract method should be same in both the abstract class and its derived class
-          An abstract method cannot have the modifier virtual. Because an abstract method is implicitly virtual.
-          An abstract member cannot be static

EX :
abstract class absClass1
{
    public abstract int AddTwoNumbers(int Num1, int Num2);
    public abstract int MultiplyTwoNumbers(int Num1, int Num2);
}
//Abstract Class2
abstract class absClass2:absClass1
{
    //Implementing AddTwoNumbers
    public override int AddTwoNumbers(int Num1, int Num2)
    {
        return Num1+Num2;
    }
}
//Derived class from absClass2
class absDerived:absClass2
{
    //Implementing MultiplyTwoNumbers
    public override int MultiplyTwoNumbers(int Num1, int Num2)
    {
        return Num1*Num2;   
    }
 }

Comments (0)