A

Admin • 828.03K Points
Coach

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: 10
  • Filed under category Java
  • Hashtags:

Explanation by: Admin
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.