nerdexam
Exams1Z0-803Questions#117
Oracle

1Z0-803 · Question #117

1Z0-803 Question #117: Real Exam Question with Answer & Explanation

The correct answer is D: Prints 1 2 3 4 5 six times. See the full explanation below for the reasoning.

Question

Given: public class Natural { private int i; void disp() { while (i <= 5) { for (int i = 1; i <= 5; ) { System.out.print(i + " "); i++; } i++; } } public static void main (String args[]) { new Natural().disp(); } }

Options

  • APrints 1 2 3 4 5 once
  • BPrints 1 3 5 once
  • CPrints 1 2 3 4 5 five times
  • DPrints 1 2 3 4 5 six times
  • ECompilation fails

Community Discussion

No community discussion yet for this question.

Full 1Z0-803 Practice