constructor in Java

A constructor in Java is a special method that is used to initialize objects. The constructor is called when an object of a class is created. It can be used to set initial values for object attributes.
You don't have to provide any constructors for your class, but you must be careful when doing this. The compiler automatically provides a no-argument, default constructor for any class without constructors. This default constructor will call the no-argument constructor of the superclass. In this situation, the compiler will complain if the superclass doesn't have a no-argument constructor so you must verify that it does. If your class has no explicit superclass, then it has an implicit superclass of Object, which does have a no-argument constructor.
Note that the constructor name must match the class name, and it cannot have a return type (like void). 
We can use any access modifier with a constructor.
Constructors can also take parameters, which is used to initialize attributes.

<b>Constructor Definition Rules:</b>
* The first statement of every constructor is a call to another constructor within the class using this(), or a call to a constructor in the direct parent class using super().
* The super() call may not be used after the first statement of the constructor.
* If no super() call is declared in a constructor, Java will insert a no-argument super()as the first statement of the constructor.
* If the parent doesn’t have a no-argument constructor and the child doesn’t define any constructors, the compiler will throw an error and try to insert a default no-argument constructor into the child class.
* If the parent doesn’t have a no-argument constructor, the compiler requires an explicit call to a parent constructor in each child constructor.