Home

Java Overloading Quiz 5

What is the output of the following code? (write "error" if the program does not compile or throws an exception)

  class Test{
     void method(int x, double y){
     System.out.print(1);
   }
     void method(double x, int y){
     System.out.print(2);
   }

   public static void main(String[] args){
     Test t = new Test();
     t.method(1.0, 2);
     t.method(1, 2.0);
     t.method(1, 2);

   }
 }
Your answer: