Given the following code, what is output by the method call, mystery(6 * 8)? public static void mystery (int x[]) { System.out.println("A"); } public static void mystery (int x) { System.out.println("B"); } public static void mystery (String x) { System.out.println("C"); }

Respuesta :

ijeggs

Answer:

B

Explanation:

This question demonstrates the concept of method overloading

Method overloading means having different versions of the same method. In this case the method mystery() has three versions. The compiler is able to determine which method to call by their different parameters

The first implementation of mystery requires an array of integers as parameter

The second implementation requires an int variable

The third implementation requires a String

The Method call mystery(6 * 8) will output B because 6*8 evaluates to an integer which is the expected argument.