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

Complete Works of Swami Vivekananda [Volume 8,Page - 2069]

  Complete Works of Swami Vivekananda [ Volume 8, Page - 2069] Jesus Christ was God — the Personal God become man. He has manifested Himsel...