Answer:

age >= 21 && age <= 35

Either Order (usually)

In most situations, the operands of AND can be in either order. The following

age >= 21 && age <= 35 

is the equivalent of this:

age <= 35 && age >= 21 

One false is enough to make the entire expression false, regardless of the false occurs.

Warning: If the boolean expression uses the assignment operator or involves calling the methods of objects, then the order sometimes does matter. Chapter 40 describes this situation in detail. For the examples in this chapter the order of operands does not matter.

The reason for this involves an optimization that sometimes results in faster running programs. Mostly you don't need to worry about this, but make a mental note about this potential problem.

QUESTION 13:

Examine this expression:

(Monster.isAlive() && (hitpoints = Hero.move())

Do you suspect that the order of operands matters here?