0

In the First case, it returns the "String". But in Case 2, what happens when we pass NULL to Exceptions, ArithmeticExceptions and Object.

Case 1-

public class Question{
    public static void JavaHungry(String s)
    {
        System.out.println("String");
    }

    public static void JavaHungry(Object o)
    {
        System.out.println("Object");
    }

    public static void main(String[] args)
    {
        JavaHungry(null);
    }
}

Case 2 -

public class Question3{
    public static void JavaHungry(Exception e)
    {
        System.out.println("Exception");
    }

    public static void JavaHungry(Object o)
    {
        System.out.println("Object");
    }

    public static void JavaHungry(ArithmeticException ae)
    {
        System.out.println("AE");
    }

    public static void main(String[] args)
    {
        JavaHungry(null);
    }
}
Kamal Thakur
  • 151
  • 1
  • 11

0 Answers0