229k views
1 vote
What is the output of the following code: for ( ; ; ) .println("Welcome to Java");?

a) Compilation error
b) Infinite loop printing "Welcome to Java"
c) No output

User Shantesh
by
7.1k points

1 Answer

6 votes

Final answer:

The output of the code is an infinite loop printing "Welcome to Java."

Step-by-step explanation:

The code provided is an example of an infinite loop. In Java, a for loop can be written without any initialization, condition, or update expressions. This means that the loop will continue indefinitely until it is manually terminated. In this case, the loop will repeatedly execute the statement System.out.println("Welcome to Java");, resulting in the "Welcome to Java" message being printed endlessly.

User Sarasranglt
by
8.1k points