2.3k views
0 votes
What mistake is in the following code?

public static double mystery (double a) {
System.out.println(a * 3.14);
}


1. The method cannot return a double.
2. It should say return true;
3. The parameter should be a boolean type.
4. There should not be a return statement.
5. The double should be changed to void since the method does not return a value.

1 Answer

1 vote
5. The double should be changed to void.

It says public static DOUBLE mystery()

this means that the method should RETURN A DOUBLE

but the method doesn't. If you change it to void so it looks like

public static void mystery()

then it'll be okay.
User Murrekatt
by
7.1k points