Multiple choice

What will be the output of the program? public class SqrtExample { public static void main(String [] args) { double value = -9.0; System.out.println( Math.sqrt(value)); } }

  1. 3.0

  2. -3.0

  3. NaN

  4. Compilation fails.

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

The sqrt() method returns NaN (not a number) when it's argument is less than zero.