Computer Applications

Read the following text and choose the correct answer:

Java constructor overloading is a technique in which a class can have any number of constructors that differ in parameter list. The compiler differentiates these constructors by taking into account the number of parameters in the list and their type.

Why do we use constructor overloading?

  1. To use different types of constructors.
  2. Because it's a feature provided.
  3. To initialise the object in different ways.
  4. To differentiate one constructor from another.

Java Constructors

5 Likes

Answer

To initialise the object in different ways.

Reason — Constructor overloading is used to initialise the object in different ways. A user can create multiple constructors for a class with different signatures based on the number and type of arguments.

Answered By

4 Likes


Related Questions