ICSE Class 10 Computer Applications Question 53 of 69

Iterative Constructs in Java — Question 8

Back to all questions
8
Question

Question 8

How many times will the following code print "Java"?

for (int i = 1; i <= 5; i ++);    
{
    System.out.println("Java");
}  
  1. 0
  2. 1
  3. 5
  4. 4
Answer

1

Reason — Since for loop has a semicolon at its end, the block following the loop will be executed after the for loop is terminated. Thus, Java will be printed only once.