D

Deepak Sahoo • 10.78K Points
Tutor II

Q. Which of the following is the correct syntax for a for loop in Java?

  • (A) for (int i = 0; i < 10; i++) { System.out.println(“Hello”); }
  • (B) for (int i = 0; i < 10; i++) System.out.println(“Hello”);
  • (C) for (i = 0; i < 10; i++) { System.out.println(“Hello”); }
  • (D) for (int i = 0; i < 10) { System.out.println(“Hello”); }
  • Correct Answer - Option(A)
  • Views: 156
  • Filed under category JAVA

Explanation by: Deepak Sahoo
The for loop initializes a counter variable, tests a condition, and increments the counter variable on each iteration.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.


Question analytics