ICSE Class 10 Computer Applications Question 56 of 69

Iterative Constructs in Java — Question 11

Back to all questions
11
Question

Question 11

Which of the following for loops will cause the body of the loop to be executed 10 times?

  1. for (int i = 0; i <= 10; i++)
  2. for (int i = 1; i < 10; i++ )
  3. for (int i = 10; i > 1; i-- )
  4. for (int i = 0; i < 10; i++ )
Answer

for (int i = 0; i < 10; i++ )

Reason — The initial value of i is 0 and the test expression i < 10 will remain true till the value of i becomes 9. So, the body of the loop will be executed till the value of i remains between 0 to 9, i.e. 10 times.