char c = 'B';
if (c >= 'A' && c <= 'Z') {
System.out.println("upper");
} else {
System.out.println("other");
}What is printed?
- Acheck_circle
upper
- 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.