BEI - Boolean Expressions (Lesson)
Boolean Expressions
Introduction
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").
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
Problets Practice
- Click HERE to visit Problets website. Links to an external site.
- Click on Topics.
- Choose Topic: Relational Expressions, Language: Java.
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-It! Self-Check
- Go to the PracticeIt website Links to an external site..
- Log in and click Start Practicing!.
- Go to the most recent edition.
- Click on Chapter 4: Conditional Execution.
- Complete Self-Check: 4.2
IMAGES CREATED BY GAVS