Compound Boolean Expressions

AP Computer Science A· difficulty 4/5

int a = 5;
int b = 10;
int c = 15;
boolean result = (a < b && b < c) || (a > c);
System.out.println(result);

What is printed?

  • A

    false

  • B

    true

    check_circle
  • C

    5

  • D

    15

Explanation

a < b (5<10) is true AND b < c (10<15) is true, so the left side is true. true || anything = true.

Want 10 more like this — adaptive to your weak spots?

Related questions