🎴 Flashcard Mode

Java Programming Basics and Oracle Database Administration

Card1 / 5
Mastered0
Review0
QuestionClick to flip

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

AnswerClick to flip back
A
double i = 0.0/0.0
💡 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.

Change Mode