← Unit 1 · all exercises
Saved in this browser only

Even or odd

Write a method that returns true when the number it is given is even, and false when it is odd. Zero is even, and negative numbers count too.

boolean isEven(int n)

Solution.java
Loading editor…
Results

Examples

  • isEven(4) → true4 divides evenly by 2
  • isEven(7) → false

There are also 4 hidden tests you can't see. Solve the problem, not the examples.