Multiple choice java

Can you compare a boolean to an integer?

  1. Yes

  2. No

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Java enforces strong typing - boolean and numeric types are incompatible. You cannot use ==, <, >, or other comparison operators between boolean and int. Such code will not compile.