ICSE Class 9 Computer Applications Question 4 of 29

Iterative Constructs in Java — Question 4

Back to all questions
4
Question

Question 4(i)

Identify all the errors in the following repetitive statements.

for	(int i = 5; i > 0; i++)
{
    System.out.println("Java");
}
Answer

The test expression i > 0 will always remain true and hence, the for loop will become an infinite loop and keep on iterating.