Oracle
1Z0-850 · Question #53
Given: 1. class Test { 2. public static void main(String args[]) { 3. for (int i = 1; i < 5; i++) { 4. if (i == 2) { 5. continue; 6. } 7. System.out.print(" i = " + i); 8. } 9. } 10. } What is the…
The correct answer is C. i=1i=3i=4. See the full explanation below for the reasoning.
Question
Given:
- class Test {
- public static void main(String args[]) {
- for (int i = 1; i < 5; i++) {
- if (i == 2) {
- continue;
- }
- System.out.print(" i = " + i);
- }
- }
- } What is the result?
Options
- Ai=1i=3i=4i=5
- Bi=1
- Ci=1i=3i=4
- DThe code runs with no output.
- Ei=1i=2i=4
- Fi=1i=2i=4i=5
- GCompilation fails.
How the community answered
(36 responses)- A3% (1)
- B6% (2)
- C78% (28)
- F11% (4)
- G3% (1)
Community Discussion
No community discussion yet for this question.