Wednesday, September 5, 2012

Why can't create object of an abstract class?



An abstract type is defined largely as one that can't be created. You can create subtypes of it, but not of that type itself. The CLI will not let you do this.

An abstract class has a protected constructor (by default) allowing derived types to initialize it.

Further, if we go with object creation process by CLR, an object of class can only be created if its FULL memory requirement is known as compilation time. considering anstract class is a "Template" or "Incomplete" class, compiler is not able to get its full memory requirement hence you can't proceed.

Abstract classes have the following features:

  • An abstract class cannot be instantiated.
  • An abstract class may contain abstract methods and accessors.
  • It is not possible to modify an abstract class with the sealed modifier, which means that the class cannot be inherited.
  • A non-abstract class derived from an abstract class must include actual implementations of all inherited abstract methods and accessors.