#
14. Analyze the following code.
public class Test {
public static void main(String[] args) {
System.out.println(max(1, 2));
}
public static double max(int num1, double num2) {
System.out.println(“max(int, double) is invoked”);
A. The program runs and prints 2 followed by “max(double, int)” is invoked.
B. The program cannot compile because the compiler cannot determine which max method should be
invoked.
C. The program runs and prints “max(int, double) is invoked” followed by 2.
D. The program runs and prints 2 followed by “max(int, double)” is invoked.
E. The program cannot compile because you cannot have the print statement in a non-void method.
#
15. Analyze the following code:
public class Test {
public static void main(String[] args) {
System.out.println(xMethod(5, 500L));
}
public static int xMethod(int n, long l) {
System.out.println(“int, long”);
return n;
}
public static long xMethod(long n, long l) {
System.out.println(“long, long”);
return n;