Constructor

 Constructor

1.It is a special member function of class that executes when we create the instance(object) of that class.in other word we can say that there is no need to call a constructor.
2.Its name is same as class name.
3.It has no return type.
4.It may be parameterized or non-parameterized.
5.It is used to initialize class level variable.

Types of constructor

There are two types of constructor.

  • Default Constructor.
  • Parameterized Constructor.

Default Constructor

The constructor with no parameter is called default constructor.

Parameterized Constructor

The constructor with parameter is called Parameterized constructor.

Destructor

1.There is no destructor in JAVA.

Post a Comment

0 Comments