A

Admin • 828.43K Points
Coach

Q. What is the output?

Code:
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++) {
System.out.print(i + "-" + j + " ");
}
}
  • (A) 0-0 0-1 1-0 1-1 2-0 2-1
  • (B) 0-0 1-0 2-0
  • (C) 0-1 1-1 2-1
  • (D) 0-0 1-1 2-2
  • Correct Answer - Option(A)
  • Views: 15
  • Filed under category Java
  • Hashtags: Java Loops

Explanation by: Admin
Nested loops iterate and print all combinations of i and j.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.