What is the result?
B. a few
C. Compilation fails.
D. The output is not predictable.
E. An exception is thrown at runtime.
Answer is C,
And explanation was given as: C is correct, compilation fails. The var-args declaration is fine, but invade takes a short,
so the argument 7 needs to be cast to a short. With the cast, the answer is B, 'a few'.
But following line compiles fine
short s = 7;
My question is why cast is necessary while passing int as parameter in invade(7) method, I thought that 7 is implicitly converted to short??
Sage of The Monstrous Toad of Mount Myoboku
Joined: Sep 06, 2009
while passing arguments casting isnt done....we have to provide them ourselves