BEI - Boolean Expressions (Lesson)

APCompSci_LessonTopBanner.png

Boolean Expressions

Introduction

George Boole 

Booleans, named after George Boole, the founder of Boolean logic, are one of the eight primitive data types, and they are used to make yes/no decisions in Java. Booleans are the basis for all control structures in Java. The two boolean values: true ("yes") and false ("no").

Duck saying Remember, boolean values are all lowercase and declared like any other kind of variable. 

Relationship Operators

The way variables and operators are sequenced and combined in an expression determines the computed result.

When using a boolean expression we will need to compare it to some value in order to test if it is true or false. The following is a list of relationship operators that can be used:

== Equal to
!= Not equal to
> Greater than
>= Greater than or equal to
< Less than
<= Less than or equal to

Primitive data types and reference values can be compared using the relational operators, ==, , =, and !=.

Arithmetic expression values can be compared using the relational operators, , , =, and =. Any expression using these relational operators will evaluate to a boolean value.

 

Relationship Operators Practice

Practice Icon Problets Practice

This will allow you to practice evaluating expressions using relationship operators. Be careful; the more mistakes you make, the more problems you must complete. It will take approximately 40 minutes to complete this activity.

View the following video to see how to get started with the Problets Practice.

 

 

Practice Icon Practice-It! Self-Check

APCompSci_LessonBottomBanner.pngIMAGES CREATED BY GAVS