Short-circuit evaluation
Short-hand evaluation
Short evaluation
Circuit evaluation
Answer is Right!
Answer is Wrong!
The correct answer is: Short-circuit evaluation.
The And
operator checks both the sub-conditions, while the OrElse
For example, the following code will only print “Hello” because the first condition is true:
if (condition1 && condition2) {
print("Hello");
}
However, the following code will print both “Hello” and “World” because the second condition is evaluated even though the first condition is true:
if (condition1 || condition2) {
print("Hello");
print("World");
}
Short-circuit evaluation can be useful for performance reasons, as it can prevent unnecessary calculations.