nerdexam
Oracle

1Z0-808 · Question #58

1Z0-808 Question #58: Real Exam Question with Answer & Explanation

Sign in or unlock 1Z0-808 to reveal the answer and full explanation for question #58. The question stem and answer options stay visible for context.

Using Loop Constructs

Question

Given the code fragment:
  1. public static void main(String[] args) {
  2. int x = 5;
  3. while (isAvailable(x)) {
  4. System.out.print(x);
  5. }
  6. }
  7. public static boolean isAvailable(int x) {
  8. return x-- > 0 ? true : false;
  9. }
Which modification enables the code to print 54321?

Options

  • AReplace line 6 with System. out. print (-x);
  • BAt line 7, insert x --;
  • CReplace line 6 with --x; and, at line 7, insert System. out. print (x);
  • DReplace line 12 With return (x > 0) ? false: true;

Unlock 1Z0-808 to see the answer

You've previewed enough free 1Z0-808 questions. Unlock 1Z0-808 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Topics

#Post-decrement operator#Method parameters#While loop#Loop termination
Full 1Z0-808 Practice