KnowledgeBoat Logo
|

Computer Applications

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

Java Iterative Stmts

3 Likes

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.

Answered By

2 Likes


Related Questions