Can abstract class have constructors?

 Posted by Ddd on 2/12/2011 | Category: .NET Framework Interview questions | Views: 4366 | Points: 40
Answer:

Yes, an abstract class does have a constructor.
It will be called when it subclass is instantiated.

example:
abstract class bank

{
public bank()
{
Console.WriteLine("bank");
}

}
class icici : bank
{
icici()
{
Console.WriteLine("icici");
}
static void Main()
{
bank b = new icici();

}
}


//Output:

when the object of icici class is created,
They will be displayed in the output.
bank
icici


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response