Question 16
Back to Exercise
What is the output of the following Java program?
public class Main {
public static void main(String[] args) {
for (int i = 1; i <= 4; i++) {
for (int j = i; j >= 1; j--) System.out.print(j);
System.out.println();
}
}
}
- A 1 21 321 4321 Correct
- B 1 12 123 1234
- C 4321 321 21 1
- D 1 22 333 4444
Correct Answer: Option A
Each row counts down from the row number to 1.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!