Machine-translated by Google. Questions are authored in English.
Top

Discussion

Assertion (A): Short circuit evaluation of a boolean expression avoids computing a value at all.
Reason (R): Each subexpression is given the destinations to jump to, so control reaches the right place without any result being stored.

  • A.Both A and R are true, but R is not the correct explanation of A
  • B.A is true but R is false
  • C.A is false but R is true
  • D.Both A and R are true, and R is the correct explanation of A

Answer: D

Both are true and the reason gives the mechanism, and it also explains the semantics. Because the second operand is never reached when the first settles the outcome, side effects in it do not occur, which languages specify deliberately.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.