Computer Applications
What is constructor overloading?
Java Constructors
7 Likes
Answer
Constructor overloading is a technique in Java through which a class can have more than one constructor with different parameter lists. The different constructors of the class are differentiated by the compiler using the number of parameters in the list and their types. For example, a class Employee can have 3 constructors as shown below:
Employee(long empId)
Employee(String name, double salary)
Employee(long empId, String name)
Due to constructor overloading, all the 3 constructors are valid for Employee class.
Answered By
6 Likes