Home » JAVA Programming » Methods » Question
  1. What is the output of the following code?

    public class output
    {
    public void method1 (int i,float f)
    {
    System.out.println(" int float method");
    }

    public void method2(float f,int i);
    {
    System.out.println("float int method");
    }

    public static void main(String[]args)
    {
    output s=new output();
    s.method1(10,10);
    }
    }
    1. float int method
    2. int float method
    3. Runtime error
    4. Compiletime error
    5. None of these
Correct Option: D

While resolving overloaded method, compiler automatically promotes if exact match is not found. But in this case, which one to promote is an ambiguity.



Your comments will be displayed only after manual approval.