27.9k views
5 votes
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");
}

A

B

C

CA

CB

Which of the following is true about overloaded methods?

Java cannot use a method's return type to tell two overloaded methods apart.

Java cannot use a method's parameters to tell two overloaded methods apart.

You can only overload methods that have parameters.

All overloaded methods must have different names.

None of the above

Given the following code, what is output by the method call, mystery (5, 7.0015)?

public static void mystery (int a) {
System.out.println("A");

1 Answer

4 votes

Answer:

The answers are: Letter B, Java cannot use a method's return type to tell two overloaded methods apart, and public static void mystery (int a, double b) { System.out.println

Step-by-step explanation:

  • public static void mystery (int x) { System.out.println("B");
  • Java cannot use a method's return type to tell two overloaded methods apart.
  • public static void mystery (int a, double b) { System.out.println
User Claudiu Papasteri
by
6.5k points