Describe how short-circuit evaluation works when evaluating compound Boolean expressions. Show an example.
What will be an ideal response?
The expressions in each part of a compound Boolean expression are evaluated only as much as necessary to determine whether the entire expression is true or false. This feature is called short-circuit evaluation. With the && operator, both Boolean expressions must be true before the action in the statement can occur. If the first expression is false, the second expression is never evaluated because its value does not matter. For example, if a is not greater than LIMIT in the following if statement, then the evaluation is complete because there is no need to evaluate whether b is greater than LIMIT.
if(a > LIMIT && b > LIMIT)
WriteLine("Both are greater than LIMIT");
You might also like to view...
To present key concepts, ____ can be used in slides.
A. titles B. graphs C. bullet items D. numerical data
After you start your computer and enter your username and password, ________ displays in Windows 8
A) the desktop B) each Charm C) the Mini toolbar D) the Start screen
In what type of cloud computing does the customer have some control over the operating systems, storage, and their installed applications?
A. Application as a Service B. Infrastructure as a Service C. Software as a Service D. System as a Service
Alice would like to add another object to a security model and grant herself rights to that object. Which one of the rules in the Take-Grant protection model would allow her to complete this operation?
A. Take rule B. Grant rule C. Create rule D. Remove rule