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

100 Research Ideas on AI 💡

🧠 Machine Learning and Deep Learning (1–20) * 1. Transfer learning: Teaching an AI a task (like recognizing cars) and reusing that knowledg...