How many types of constructors are used in Java?

DWQA QuestionsCategory: JavaHow many types of constructors are used in Java?
Editor Staff asked 11 months ago

How many types of constructors are used in Java?

1 Answers
Editor Staff answered 11 months ago

Based on the parameters passed in the constructors, there are two types of constructors in Java.
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.
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.
Java Constructors