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

In Java, Math.max(double, double) is invoked due to overload resolution converting the float argument to a double. Double.POSITIVE_INFINITY and Float.POSITIVE_INFINITY are mathematically equal, but the method returns a double type representation of positive infinity.