Computer Science, asked by hamzasajed87, 1 year ago

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 someshwarte
1

there are 2 equal to signs after 2 like this

(x%2==0 )

&lt;font size="large" color="red"&gt;&lt;marquee&gt;hope this answer helped you . Thank you .</p><p>mark mine as the brainliest answer . &lt;/marquee&gt;&lt;/font&gt;


hamzasajed87: the right choose
hamzasajed87: The method header says nothing is going to be returned, but there are return statements in the body of the method
Similar questions