Constructors
Constructors
A constructor is a special method that has the same name as the class name
* It must not have any return type, not even void, else it will be treated as an ordinary method
* Should not be of a private type, otherwise you will not be able to create an object of a class
* Should not be static because it will be invoked each time an object of a class is created
* Can be overloaded
If constructors are not manually declared, the java compiler automatically provides a default
constructor for a class to initialize all the instance variables of a class with their default values
Constructors are required in a program to initialize the variables with meaningful values
Default Constructors –
Non-parameterized constructors
Parameterised Constructors –
Contain parameters