12 < 6 && 18 > 1 A good answer might be:false | ||||||||
Short-circuit AND Operator
You may have noticed something in answering the question: you can get the correct answer to the question by evaluating just the first part of the expression: Since false && anything is false, there is no need to continue after the first false has been encountered. In fact, this is how Java operates:12 < 6 && 18 > 1 ------ false
To evaluate
This idea is called short-circuit evaluation.
Programmers frequently make use of this feature.
For example,
say that two methods returning true/false values
are combined in a boolean expression:
if ( reallyLongAndComplicatedMethod() && simpleMethod() ) .... | ||||||||
QUESTION 2:Suggest a better (but logically identical) way to arrange this boolean expression. Click Here after you have answered the question |