Constructor

 Constructor: Constructor is a special type of method that is used to initialize the object.

Properties of constructor :

 . Constructor has the same name as that of the class it belongs.

.  It has no return type not even void.

. It is called automatically.

. Two type constructor :  (i) Default Constructor [No parameter]

                                        (ii) Parametrized Constructor.

. In Java compiler provides a default constructor by default.


Example of a parametrized Constructor 


Example of a default Constructor 


Output 












Comments