Multiple choice technology programming languages

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

  1. Char i = 9

  2. int i = 3/7

  3. String i = "abc"

  4. int i = 0

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

In Java, adding a string to another string (i + 0) performs string concatenation (e.g., "abc" + 0 yields "abc0"). Since "abc" is not equal to "abc0", i != i + 0 evaluates to true, and it loops indefinitely. For numeric types, adding 0 does not change the value, so the loop terminates immediately.