Home » mcq » Visual basic » And operator checks both the sub-conditions whereas OrElse operator does . . . . . . . .
Short-circuit evaluation
Short-hand evaluation
Short evaluation
Circuit evaluation
Answer is Wrong!
Answer is Right!
The correct answer is: Short-circuit evaluation.
The And
operator checks both the sub-conditions, while the OrElse
operator only checks the first sub-condition. If the first sub-condition is true, the second sub-condition is not evaluated. This is called short-circuit evaluation.
For
81.2z"/>
Subscribe on YouTube
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.