What is the problem with the following code?
public static void myMethod(int x) { if (x % 2 == 0) { return true; } else { return false; } }
1-There are two return calls and there can only be one per method.
2-A boolean is being returned but it should be an int
3-Since there is a return at the top of the program all the code after it is "unreachable"
4-The method header says nothing is going to be returned, but there are return statements in the body of the method
Answers
Answered by
1
there are 2 equal to signs after 2 like this
(x%2==0 )
hamzasajed87:
the right choose
Similar questions