Page 1 of 1

About Question enthuware.ocajp.i.v7.2.1058 :

Posted: Fri Oct 19, 2012 12:23 pm
by ETS User
The explanation for this says that if the third test1 method - test1(int i, int j) were removed the the program would not compile because the remaining two methods are equally applicable and equally specific.

On my machine with Java7 installed I get no compile time or runtime errors when I remove the third method with the two int parameters. My machine returns 1 as the output. So it returns the one with the int and the var-args over the method with just var-args.

Re: About Question enthuware.ocajp.i.v7.2.1058 :

Posted: Fri Oct 19, 2012 2:20 pm
by admin
Are you sure you ran the same code as given in the question? Because I tried it and I get:
Varargs.java:3: error: reference to test1 is ambiguous, both method test1(int,in
t...) in Varargs and method test1(int...) in Varargs match
test1(10, 20); //1
^
1 error

Re: About Question enthuware.ocajp.i.v7.2.1058 :

Posted: Mon Nov 23, 2015 2:06 pm
by meghajor
I ran the same code on my computer.I commented two methods. The uncommented method is printing its output.
But when I only comment the last method, it says ambiguous.
Pls explain

Re: About Question enthuware.ocajp.i.v7.2.1058 :

Posted: Mon Nov 23, 2015 7:34 pm
by admin
Please post the exact code that you ran and the expected and actual output so that it is clear what you are asking.
thank you,
Paul.