Task 5 of 8 · 0 solved · 8 to go0%
You can read the problem, but answers are checked only for signed-in students. Sign in to answer →

1.3 Types — boolean from a comparison

Lesson

boolean is the result of a comparison

A comparison like 3 > 2 produces a boolean — true or false. A boolean holds only these two values (not 1/0).


Worked example

boolean ready = (3 > 2);
System.out.println(ready);  // true

▶ Try it: run this, then change something and run it again.



What does System.out.println(3 > 2); print?


True or false?


Type exactly what this prints:

boolean b = (10 > 3);
System.out.println(b);

Task

Write the body of isPositive that takes an int n and returns true when n is greater than 0, and false otherwise.

For example, isPositive(5) returns true; isPositive(-2) returns false.