What will be the output of the following Java code?

class San
{
 public void m1 (int i,float f)
 {
  System.out.println(" int float method");
 }
 
 public void m1(float f,int i);
  {
  System.out.println("float int method");
  }
 
  public static void main(String[]args)
  {
    San s=new San();
        s.m1(20,20);
  }
}

a) int float method
b) float int method
c) compile time error
d) run time error

1 thought on “What will be the output of the following Java code?”

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

Leave a Comment