Constructor
Jun 3, 2021
Constructor is a special method/special member of the class which is used to initialize the data members(variables & methods).
Key Points of Constructor:
- Constructor name should be same as class name.
- It will not have return type.
- It will not return any value.
- It is always non static.
- Whenever you create an object, constructor will be invoked.
Syntax:
className(){
}
Constructors are of two types:
- Non Parameterized Constructor.
- Parameterized Constructor.