ICSE Class 10 Computer Applications Question 5 of 69

Iterative Constructs in Java — Question 5

Back to all questions
5
Question

Question 3(iii)

Identify all the errors in the following statements.

while (x ==	y)
{
    xx = yy;
    x = y;
}
Answer

The test expression x == y will always remain true as in each iteration x = y is executed, which will store the value of y in x. Thus, an infinite loop will be generated.