Boolean Expressions

AP Computer Science A· difficulty 3/5

char c = 'B';
if (c >= 'A' && c <= 'Z') {
  System.out.println("upper");
} else {
  System.out.println("other");
}

What is printed?

  • A

    upper

    check_circle
  • B

    other

  • C

    B

  • D

    compile error

Explanation

Characters can be compared with relational operators using their Unicode/ASCII values. 'B' is between 'A' (65) and 'Z' (90), so the condition is true.

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

Related questions