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");

if (num1 > num2)
return num1;
else
return num2;
}

public static double max(double num1, int num2) {
System.out.println("max(double, int) is invoked");

if (num1 > num2)
return num1;
else
return num2;
}
}
a. The program cannot compile because you cannot have the print statement in a non-void method.
b. The program cannot compile because the compiler cannot determine which max method should be invoked.
c. The program runs and prints 2 followed by "max(int, double)" is invoked.
d. The program runs and prints 2 followed by "max(double, int)" is invoked.
e. The program runs and prints "max(int, double) is invoked" followed by 2.


b This is known as ambiguous method invocation.

Computer Science & Information Technology

You might also like to view...

Which of the following SDKs can you NOT use on a Mac?

A. Android B. webOS C. Symbian D. iOS

Computer Science & Information Technology

A stacked column chart displays multiple columns for each category

Indicate whether the statement is true or false

Computer Science & Information Technology

Give the command line for displaying the table of contents of your library file ~/lib/mylib.a. Run this command on your system and show its output.

What will be an ideal response?

Computer Science & Information Technology

The Research task pane can be used to translate text in ________ languages

A) 20 B) 5 C) 2 D) 36

Computer Science & Information Technology