Multiple choice technology web technology

if(0.0 == -0.0) { System.out.println("true"); } else{ System.out.println("false"); }

  1. prints false

  2. prints true

  3. Complier error

  4. None of the above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

According to the IEEE 754 standard for floating-point arithmetic, which Java adheres to, positive zero and negative zero are mathematically and logically considered equal. Therefore, the comparison 0.0 == -0.0 evaluates to true, and the program prints "true" rather than false.