We cannot create an instance of an abstract class.So,what is the use of a constructor in an abstract class?

 Posted by vishalneeraj-24503 on 9/6/2014 | Category: OOPS Interview questions | Views: 1988 | Points: 40

Though we cannot create an instance of an abstract class,we can create instances of the classes that are derived from the abstract class.So,when an instance of derived class is created,the parent abstract class constructor is automatically called.

Note: Abstract classes can not be directly instantiated.The abstract class constructor gets executed through a derived class.So,it is a good practice to use protected access modifier with abstract class constructor.Using public does not make sense.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response