Java.lang Class

Q1: 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));
    }
}

A 3.0

B -3.0

C NaN

D Compilation fails.

ANS:A - 3.0

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



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.