limited time offer

What is a constructor overloading in Java?

In Java, constructor overloading is a technique of adding any number of constructors to a class each having a different parameter list. The compiler uses the number of parameters and their types in the list to differentiate the overloaded constructors.

class Demo
{
    int i;

    public Demo(int a)
    {
        i = k;
    }
    
    public Demo(int a, int b)
    {
        //body
    }
}

In above example, Demo() constructor is overloaded.