Constructor : Constructor was special method present in every class responsible for initializing the variables of a class. the name of a constructor method is same as class name. A constructor method was non-value returning method. Every class requires a constructor . If at all it has to execute.
Syntax:
[ <Modifiers>] <name>([<param def's>])
{
statements
}
Constructors are two types :
Syntax:
[ <Modifiers>] <name>([<param def's>])
{
statements
}
Constructors are two types :
- Default Zero argument constructor.
- Parameterized constructor.
No comments:
Post a Comment