Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following Java code?
class isNaN_output
{
public static void main(String args[])
{
Double d = new Double(1 / 0.);
boolean x = d.isNaN();
System.out.print(x);
}
}

What will be the output of the following Java code?
class isNaN_output
{
public static void main(String args[])
{
Double d = new Double(1 / 0.);
boolean x = d.isNaN();
System.out.print(x);
}
}
a) 0
b) 1
c) true
d) false

Answer: d
Explanation: isisNaN() method returns true is the value being tested is a number. 1/0. is infinitely large in magnitude, which cannot be defined as a number hence false is stored in x.
Output:
false

Join The Discussion