What is the result of the following code snippet?
int i = 1;
while (i <= 5) {
System.out.print(i + " ");
i++;
}
while (i <= 5) {
System.out.print(i + " ");
i++;
}
A. 5 4 3 2
B. 5 4 3 2 1
C. 1 2 3 4
D. 1 2 3 4 5
Answer: Option D
Related Questions on Flow Control
What is the purpose of the "if" statement in Java?
A. To execute a block of code conditionally
B. To create loops
C. To declare variables
D. To define methods
A. No output
B. Error
C. Hello
D. 5
Join The Discussion