Multiple choice technology programming languages

class SRC104 { public static void main (String[] args) { System.out.print(Math.round(Float.NaN)); }} What is the result of attempting to compile and run the program?

  1. Prints: NaN

  2. Prints: 0.0

  3. Prints: 0

  4. Compile-time error

  5. Run-time error

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

Math.round(Float.NaN) returns 0, not NaN. The round method converts the float NaN to an integer, and integer NaN is represented as 0. This is a subtle behavior of the Math.round method with NaN inputs.