AP® Computer Science A glossary

Logical operators

Also called: Boolean operators, and, or, not

Course: AP® Computer Science A Shows up in: Unit 2: Selection and Iteration

The operators ! (not), && (and) and || (or), which combine Boolean expressions into a compound Boolean expression. Precedence: !, then &&, then ||.

Appears in the course and exam description (CED): 2.5.A.1

a && b is true only when both are true. a || b is true when at least one is true. !a flips the value.

boolean a = true;
boolean b = false;
System.out.println(a || b && false);

Output:

true
Learn it properly, with a checkpoint 2.5 Compound Boolean Expressions

Related terms

Was this page helpful?

No names are ever shown, and every public comment is checked by us first. Please do not include personal details. To get a reply, email [email protected].

↑ Top

Enlarged view of the selected figure