Java.lang Class

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

A -2

B NaN

C Compile Error

D Runtime Exception

ANS:A - -2

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.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.