Home

Java Overloading Quiz 3

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){
    System.out.print(1);
  }
  void method(int...a){
    System.out.print(2);
  }
  public static void main(String[] args){
    Test t = new Test();
    t.method();
    t.method(1);
    t.method(1, 2);
  }
}

Your answer: