Computer Applications

What is meant by a constructor?

Java Constructors

36 Likes

Answer

A constructor is a member method having the same name as that of a class and is used to initialise the instance variables of the objects. It is invoked at the time of creating any object of the class. For example:

Employee emp = new Employee();

Here, Employee() is invoking a default constructor.

Answered By

23 Likes


Related Questions