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

1.6 Logic — not (!)

Lesson

! (not)

! flips a boolean: !true is false, and !false is true. !(condition) is true exactly when the condition is false.


Worked example

!true       // false
!false      // true
!(5 > 3)    // false   (5 > 3 is true, ! flips it)
!(2 > 5)    // true    (2 > 5 is false, ! flips it)

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



What is !true?


What is !(5 > 3)?


What is !(2 > 5)?


True or false?


Sort each expression by its value.


Type exactly what this program prints.

public class Main { public static void main(String[] a){
    System.out.println(!(4 > 2));
}}