Type of Constructor

There are two types of constructor and these are following:-

Static Constructor(also known as class constructor)

Non static Constructor(also known as instance constructor)

Static Constructor

Static constructor is that constructor which is called before the object creation of class. Basically static constructor is used to initialize the static variable of the class.

Syntax of Static Constructor

Static class_name(){ }

Features of the static Constructor

Non static Constructor

These constructors are used to initialize the value of member variable of the class at the time of creation of object.

Type of non static constructor

Default constructor

Default constructor is a constructor with no argument

Interview Questions based on Default constructor

public class_name()
{         }

Parametrized constructor

		Public class_name(int x)


Copy constructor

Copy constructor is a constructor having argument of same class

I have created a class name calculator and in copy constructor we pass the object of same class

		Public calculator(calculator cal)
{      }