nerdexam
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:
  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 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)
  • A
    3% (1)
  • B
    6% (2)
  • C
    78% (28)
  • F
    11% (4)
  • G
    3% (1)

Community Discussion

No community discussion yet for this question.

Full 1Z0-850 Practice