What happens when you compare two primitives of different numerical types?
-
compiler error
-
smaller type is promoted
-
must explicitly cast
-
none of the above
B
Correct answer
Explanation
Java automatically promotes the smaller primitive type to match the larger type during comparison operations. This is part of binary numeric promotion - for example, an int compared to a long is promoted to long, a float compared to a double is promoted to double. This promotion happens automatically without requiring explicit casting from the programmer.