What is Constructor?
A constructor is used to initialize a newly created object.
- It's called just after memory is allocated for the object.
- It can be used to initialize objects.
- It isn't mandatory to write a constructor for the class.
- Name of constructor is same as the class name.
- Can't be inherited.
- Constructor is invoked whenever an object of its associated class is created.