Home » Java Programming » Java.lang Class

What will be the output of the program? System.out.println(Math.sqrt(-4D));

Correct Answer: NaN

Explanation:

It is not possible in regular mathematics to get a value for the square-root of a negative number therefore a NaN will be returned because the code is valid.

← Previous Question Next Question→

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion