What will be the output of the following program:

public class VarTest {
    public static void main(String[] X) {
        Integer x = 1;
        Integer y = 2;
        print(1);
        print(1,2);
        print(x);
        print(x,y);
    }
    static void print(int i) {
        System.out.print(1);
    }
    static void print(Integer... i) {
        System.out.print(2);
    }
    static void print(Integer i) {
        System.out.print(3);
    }
    static void print(int... i) {
        System.out.print(4);
    }
}
Explanation
Method calls print(1,2) and print(x,y) are ambiguous.
You must leave only one of methods print(Integer... i) and print(int... i)

Follow CodeGalaxy

Mobile Beta

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