Home > Interview Questions > C#.NET > Can an abstract class have a constructor? If so what is the use?

Can an abstract class have a constructor? If so what is the use?

by RAVINDRA   on 19/08/2014   Category: C#.NET   |  Level: Intermediate   |  Views: 1990    |  Points: 25     |  Starter 


Yes, an abstract class can have a constructor. In general, a class constructor is used to initialise fields. Along the same lines, an abstract class constructor is used to initialise fields of the abstract class. You would provide a constructor for an abstract class if you want to initialise certain fields of the abstract class before the instantiation of a child-class takes place. An abstract class constructor can also be used to execute code that is relevant for every child class. This prevents duplicate code.


« You cannot create an instance of an abstract class. So, what is the use of a constructor in an abstract class?
» How to find nth highest salary in sql
Post Question  |  Question Home

Recent Posts

User Responses


No response found, be the first to review this question.

Submit feedback about this code snippet

Please sign in to post feedback

Latest Posts