Constructor is a special type of method in a class that is used initialise an object, that is a constructor is called automatically when an object of a class is created.A constructor is mainly used to initiallise the values to the variables in the functions.
The constructor has some special properties that are:
The most common types of constructors in Java programming are:
Default constructor and
Parameterised constructor
The constructor has some special properties that are:
- Constructor cannot have any return type ,not even void.
- The name of the constructor should be same as the class name.
The most common types of constructors in Java programming are:
Default constructor and
Parameterised constructor