Constructor of Abstract Class

As we know that, we cannot create the object of Abstract class. It is very important question of interview that whether we can have constructor in Abstract class or not? Yes, we can have constructor in Abstract class and we can call this constructor from derived class.

Example

In the following example, we have created constructor in Abstract class Abc and with the help of constructor chaining we have called Abstract class constructor from derived class.


	
	public abstract class Abc
{
    public int a, b;
     public Abc(int a1, int b1)
    {
        a = a1;
        b = b1;
    }
   
}
public class Pqr : Abc
{
    public Pqr() : base(3, 4)
    {

    }
    
}