Multiple choice technology programming languages

Provide a declaration for i that turns this loop into an infinite loop: while( i != i){ }

  1. String i = "abc"

  2. double i = 0.0/0.0

  3. int i = 3/7

  4. int i = 0

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

In IEEE floating-point arithmetic, 0.0/0.0 produces NaN (Not a Number), and NaN != NaN always evaluates to true, creating an infinite loop. Integer division (3/7) equals 0, String comparison compares references, and 0 != 0 is false - only NaN creates this condition.