This module is about asking yes/no questions in code. The answers are boolean values, and you combine them with and, or, and not.
boolean
The operators > < >= <= == != compare two values and give a boolean. == tests equality (not =, which assigns); != means not equal.
>
<
>=
<=
==
!=
=
5 > 3 // true 4 == 4 // true 3 != 5 // true 4 <= 3 // false
▶ Try it: run this, then change something and run it again.
What is the value of 5 > 3?
5 > 3
What is the value of 3 != 5?
3 != 5
Type exactly what this prints:
System.out.println(4 <= 3);
Sort each comparison by its value.
Write the body of isEven that takes an int n and returns true when n is even, and false otherwise.
isEven
int n
true
n
false
For example, isEven(4) returns true; isEven(7) returns false.
isEven(4)
isEven(7)