You are on page 1of 1

Constructor-

1. Constructor initialize itself at the time of object creation


2. Constructor does not have any return type
3. Constructor name same name as a class name
4. Constructor Overload is allowed
5. Constructor Override never possible

2 types-

A] Default Constructor
B] Parameterized Constructor

#Constructor Override never possible-


Constructor looks like a method but name should be as class name and no return
value.
Overriding means what we have declared in Super class, that exactly we have to
declare in Sub class it is called Overriding. Super class name and Sub class names
are different.

If you trying to write Super class Constructor in Sub class, then Sub class will
treat that as a method not constructor because name should not match with Sub class

name. And it will give an compilation error that methods does not have return
value. So we should declare as void, then only it will compile.

You might also like