import java.util.Scanner;
class ParamConstructor
{
    int sid;
    String sname;
    ParamConstructor()
    {
        sid=125;
        sname="Sindhu";
    }
    ParamConstructor(int x,String n)
    {
        sid=x;
        sname=n;
    }
    void showdetails()
    {
        System.out.println("\nThe Default value of the student is:"+"\nSid: "+sid+"\nSname: "+sname);
    }
    void showdetails2()
    {
        System.out.println("Sid: "+sid);
        System.out.println("Name of the student is:");
        String []arr=sname.split(" ");
        if(arr.length==1)
           System.out.println("firstname: "+arr[0]);
        else if (arr.length==2)
           System.out.println("firstname: "+arr[0]+"\nmiddlename: "+arr[1]);
        else
           System.out.println("firstname: "+arr[0]+"\nmiddlename: "+arr[1]+"\nlastname: "+arr[2]);
    }
    public static void main(String[] args)
    {
        ParamConstructor o1=new ParamConstructor();
        Scanner myobj = new Scanner(System.in);
        int x=myobj.nextInt();
        myobj.nextLine();
        String n= myobj.nextLine();
        ParamConstructor o2=new ParamConstructor(x,n);
        o1.showdetails();
        o2.showdetails2();
    }
}

Embed on website

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