What happens to the result of a relational operation if both operands are NaN?

  • It returns false.
  • It returns true.
  • It throws a NaNException.
  • It throws a NullPointerException.
When both operands of a relational operation are NaN, Java returns false. This behavior is consistent with the IEEE 754 floating-point standard, which defines the behavior of floating-point numbers, including NaN. Options 2, 3, and 4 are incorrect because they don't reflect the actual behavior of Java in this situation.
Add your answer
Loading...

Leave a comment

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