What is the output of the following application?
package mypkg; // www.j a v a 2s . com public class Main { public static Long getScore(Long v) { return 2*v; // m1 } public static void main(String[] refs) { final int startTime = 4; System.out.print(getScore(startTime)); // m2 } }
C.
The variable startTime
can be automatically converted to Integer by the compiler,
but Integer is not a subclass of Long.
Therefore, the code does not compile due the wrong variable type being passed to the getScore()
method on line m2, and Option C is correct.