- Constructors are required to create objects for a class. Constructors are used to initialize the instance variables of an object.
- Constructor declaration looks like method declaration. It must have the same name as that of the class and have no return type.
- Constructors can be classified into two types, default constructors and parametarized constructors.
- If you don’t define a constructor, then the compiler creates a default constructor. Default constructors do not contain any parameters. Default constructors are created only if there are no constructors defined by us.
- Prametarized constructors are required to pass parameters on creation of objects. We can overload constructors with different datatypes as its parameters.
- Use ‘this()’ to communicate from one constructor to another constructor in the same class.
- Use ‘super()’ to communicate with super class constructor.