What are the types of Constructors ?

 Posted by Bharathi Cherukuri on 2/22/2012 | Category: C# Interview questions | Views: 4827 | Points: 40

There are three types of constructors.

1)Default Constructor
2)Parametric Constructor
3)Copy Constructor

Default Constructor :

A default constructor is a constructor which has no parameters or where it has parameters they are all defaulted.

Parametrized Constructor :

Parametrized constructors allows you to create a new instance of a class while simultaneously passing arguments to the new instance.

Copy Constructor :

A copy constructor is a special constructor which creates a new object as a copy of an existing object. The first argument of such a constructor is a reference to an object of the same type as is being constructed (const or non-const), which might be followed by parameters of any type (all having default values).

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response