go to previous page   go to home page   go to next page hear noise

Answer:

(4 < 8 ) && (12 <= 40 ) && (50 > 1)

is true


Two AND Operators

An expression with two && operators works like you expect. But let us look at the situation in detail. When the && operator is used twice in an expression, group the first && and its operands together like this:

  (4 < 8 ) && (12 <= 40 )  && (50 > 1)

is equivalent to:

( (4 < 8 ) && (12 <= 40 )) && (50 > 1)

Now evaluate that first group. The result is a true or false that is used with the next && operator:

(          true          ) && (50 > 1)

The effect of this is that for the entire expression to be true, every operand must be true.

Short-circuit evaluation is still going on, so the first false value stops evaluation and causes the entire expression to be false.


QUESTION 9:

What is the value of:

(4 < 8 ) && (  8 < 0 ) && ( 100 > 45 )