Saturday, July 22, 2023

Constructor Overloading using JAVA

 class Constructor

{
    Constructor()
    {
        System.out.println("this is without parameter");
    }
    Constructor(int x)
    {
        System.out.println("this is integer parameter");
    }
    Constructor(float x)
    {
        System.out.println("this is float parameter");
    }
    Constructor(char x)
    {
        System.out.println("this is character parameter");
    }
}
public class ConstructorOverloading {
    public static void main(String[] args) {
        Constructor ob1=new Constructor();
        Constructor ob2=new Constructor(5);
        Constructor ob3=new Constructor(10.2f);
        Constructor ob4=new Constructor('a');
    }
}

No comments:

Post a Comment

Outlook, developed by Microsoft, is a widely used personal information manager that includes an email client, calendar, task manager, contact manager, note-taking, journal, and web browsing

 Outlook, developed by Microsoft, is a widely used personal information manager that includes an email client, calendar, task manager, conta...