Mr Raj Anand

Mr Raj Anand

  • 1.6k
  • 103
  • 19.2k

Why we can't create object of Abstract class?

Aug 23 2014 1:38 AM
//An Abstract class may have public constructor but we can not able to create its object.

public
abstract class MyAbstract
{
   private int x;
   public MyAbstract(int p)
   {
      this
.x = p;
   }
}

public class MyClass : MyAbstract
{
   public MyClass(int p) : base(8)
   {
      p = 8;
   }
}

public class Hello
{
   MyAbstract abss = new MyClass(3);
   MyAbstract abss = new MyAbstract(4);
   MyClass cls = new MyAbstract(5);
}
In the above example last two line is not permissible.

Answers (5)