In Java, when evaluating an expression that contains multiple data types, the type with the highest precision and range is chosen to represent the result of the entire expression. The promotion rules are applied as follows:
-
If the expression involves double
, float
, long
, and int
, it is promoted to the type with the highest precision and range among these.
-
The precedence of types from lowest to highest precision is:
Given the presence of double
, int
, float
, and long
in the expression, the highest precision and range type is double
.
Therefore, the whole expression will be promoted to:
c) double