Multiple choice technology programming languages

What does the following expression return? Math.max(Float.POSITIVE_INFINITY,Double.POSITIVE_INFINITY);

  1. Float.POSITIVE_INFINITY

  2. Double.POSITIVE_INFINITY

  3. runtime Exception

  4. None of the Above

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

Math.max is overloaded for double and float. When comparing a float and a double, the float is promoted to a double. The result of Math.max(double, double) is a double, returning Double.POSITIVE_INFINITY.