Relation Operator

Relation Operator

  1. Which of the following will evaluate to true only if boolean expressions A, B, and C are all False?

    • not A and not (B and not C)
    • not A or not B or not C
    • not (A or B or C)
    • not (A and B and C)
    • not A or not (B or not C)
  2. Assume that a and b are integers. The boolean expression

    not (a <= b) and (a * b > 0)

    will always evaluate to True given that

    • a = b
    • a > b
    • a < b
    • a > b and b > 0
    • a > b and b < 0
  3. Given that a, b, and c are integers, consider the boolean expression

    (a < b) or not ((c == a * b) and (c < a))

    Which of the following will guarantee that the expression is True?

    • c < a is False.
    • c < a is True.
    • a < b is False.
    • c == a * b is True.
    • c == a * b is True, and c < a is True.
  4. In the following code segment, you may assume that a, b, and n are all type int.

    if (a != b and n / (a - b) > 90){
    	/* statement 1 */
    }else{
    	/* statement 2 */
    }
    /* statement 3 */

    What will happen if a == b is False?

    • /* statement 1 */ will be executed.
    • /* statement 2 */ will be executed.
    • Either /* statement 1 */ or /* statement 2 */ will be executed.
    • A compile-time error will occur.
    • An exception will be thrown.