import java.util.Scanner;
class ConstructorOverloading
{
    ConstructorOverloading()
    {
        int i=100,j=200;
        System.out.println("Inside default constructor");
        System.out.println("Value of i: "+i+" and "+"j: "+j);
    }
    ConstructorOverloading(int x)
    {
       int i=x;
        System.out.println("Inside single parameter constructor with int value = "+i);
    }
    ConstructorOverloading(String s)
    {
        String i=s;
        System.out.println("Inside single parameter constructor with String object");
        System.out.println("String Value = "+i);
    }
    ConstructorOverloading(int x,double d)
    {
       int i=x;
        double j=d;
        System.out.println("Inside double parameter constructor value of p = "+i+" and k = "+j);
    }
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
        sc.nextLine();
        String s=sc.nextLine();
        double d=sc.nextDouble();
        ConstructorOverloading co=new ConstructorOverloading();
        ConstructorOverloading co1=new ConstructorOverloading(x);
        ConstructorOverloading co2=new ConstructorOverloading(s);
        ConstructorOverloading co3=new ConstructorOverloading(x,d);
    }
    
 }

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: