Compound Boolean Expressions

AP Computer Science A· difficulty 2/5

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

What is printed?

  • A

    true

    check_circle
  • B

    false

  • C

    5

  • D

    10

Explanation

Both (a < b) which is (5 < 10) = true and (b > 0) which is (10 > 0) = true. true && true = true.

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

Related questions