ICSE Class 9 Computer Applications
Question 27 of 29
Iterative Constructs in Java — Question 5
Back to all questions 5
Question Question 5
How many times will the following code print "Hello"?
for (int i = 1; i <= 5; i++);
{
System.out.println("Hello");
}- 0
- 1
- 5
- 4
1
Reason — The for loop has a semicolon ; at the end. Thus, it becomes an empty loop and the program just waits till the loop finishes. Then the program executes the next statement System.out.println("Hello"); and prints Hello on the output screen.