0
How many types of constructors are used in Java?

Open 1 Answers 28 Views Education
How many types of constructors are used in Java?

1 Answer

0

Based on the parameters passed in the constructors, there are two types of constructors in Java.

1) Default Constructor: default constructor is the one which does not accept any value. The default constructor is mainly used to initialize the instance variable with the default values. It can also be used for performing some useful task on object creation. A default constructor is invoked implicitly by the compiler if there is no constructor defined in the class.

2) Parameterized Constructor: The parameterized constructor is the one which can initialize the instance variables with the given values. In other words, we can say that the constructors which can accept the arguments are called parameterized constructors.

by (52.6k points)
...