.Net and ASP.NET Interview Questions- Why can't we instantiate an abstract class?

 Posted by Questpond on 2/7/2011 | Category: ASP.NET Interview questions | Views: 4894 | Points: 40
Answer:

.Net and ASP.NET Interview Questions- Why can't we instantiate an abstract class?

Answers:-
This is a nice .NET interview question. Abstract class is a half defined class and there is no point in creating a object of half a defined class. So you need to define a full implementation by creating a child class and you can then create the object of the child class.

My 50 .NET interview question http://www.questpond.com


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Kishork80 on: 2/8/2011 | Points: 10
Abstract class is a normal class which can have contructor, normal method and abstract methods as well.
We can not Cannot create an instance of the abstract class or interface as per dot net.
see example below:

abstract class Test
{
public Test()//parameterless constructor
{ }
public Test(String s)//overloaded constructor
{ }
public void T1()//normal method
{ }
public abstract void T2();//abstract method
}

NOTE: if any of the method is abstract inside the class the whole class has to defined abstract (mandatory).

Login to post response