Constructor is the special type of method of a class which invokes automatically when instance of class is created. Constructor is used to object initialization and memory allocation of the class. Constructor is used to initialize private field’s value of the class whenever instance or object of class is created. Constructor can be overloaded.
When we don’t create constructor for the class, the compiler automatically create a default constructor for the class. Constructor name is always same of the class name.
Rate this :