CHAPTER 40 — Boolean Expressions and Short-circuit Operators

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to home page   hear noise   go to next page

created: 12/10/99; revised: 01/22/00, 07/18/02, 01/19/06

CHAPTER 40 — Boolean Expressions and
Short-circuit Operators

A boolean value (a true/false value) picks the branch of an if statement or allows a loop to continue. Sometimes a boolean expression is more complicated than we have seen so far in these notes. Often a program must make a decision based on a number of factors. This chapter will examine this topic and discuss some additional boolean operators.

blown fuse

Chapter Topics:

  • Short-circuit && and || operators.
  • Non-short-circuit & and | operators.
  • Expressions made with several && operators.
  • Expressions made with several || operators.
  • Expressions made with mixed && and || operators.
  • Precedence of && and || operators.

QUESTION 1:

What is the true/false value of:

12 < 6 && 18 > 1