What will be printed out as a result of the following code execution / compilation?

public class Test {
    static void m(int ... a) {
        System.out.println("1");
    }

    static void m(Integer ... a) {
        System.out.println("2");
    }

    public static void main(String[] args) {
        m(1, 2);
    }
}
Explanation
Both methods m (int ... a), and m (Integer ... a) can be applied for an m (1,2) method call. None of these methods is the most specific one, so there a compiletime error will occur (an ambiguous methods).
PS: Earlier versions of JDK8 contained an error, due to which the given code successfully compiled contrary to specifications.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes