A constructor is a particular type of method that is used to initialise the object. The constructor is invoked at the time of object creation. It constructs the values, i.e. provides data for the object that is why it is known as a constructor.
A constructor can’t be static.
There are two types of constructors:
- Default constructor (no-arg constructor)
- Parameterised constructor
- Constructor Chaining (base class constructor called first)
- Use super to call parent class constructor/methods
- Use this to call invoking object constructor/methods