Original Answer: E. The opposite of !(a != b) is (a != b), due to the precense of a logic operator. With De Morgan’s Law, the logic operator && becomes | and vice versa. The opposite of (b > 7) is (b <= 7). |
Correct Answer: B. De Morgan’s Law states that !(a && b) is equal to !a | !b. After negating the first expression, we get (!(a != b)) | !(b > 7). After negative the second expression, we get (a != b) | (b <= 7). |
Original Answer: C. This would be the correct answer if the boolean condition was changed from | to &&. However, since k is never incremented, | will always be true since k will always be less than 4. |
Correct Answer: E. Since k is never changed in the body of the while loop, it will always have a value 1 and thus less than 4. This means the boolean expression | for the while loop will always evaluate to true, and therefore lead to an infinite loop. |