Discussion Forum : Introduction To Methods And Streams
Question -


What is the output of this program?


class isNaN_output {
public static void main(String args[]) {
Double d = new Double(1 / 0.);
boolean x = d.isNaN();
System.out.print(x);
}
}
Options:
A .  0
B .  1
C .  true
D .  false
Answer: Option D

isisNaN() method returns true is the value being tested is a number. 1/0. is infinitely large in 

magnitude, which cant not be defined as a number hence false is stored in x.
Output:
$ javac isNaN_output.java
$ java isNaN_output
false



Was this answer helpful ?
Next Question
Submit Your Solution hear:

Your email address will not be published. Required fields are marked *