1z0-808 Practice Test

1z0-808 Practice Test practice questions, page 4 of 10, with answer review and explanations.

Question 16

Given the code fragment from three files: Which code fragment, when inserted at line 2, enables the code to compile?

  1. Option A
  2. Option B
  3. Option C
  4. Option D
  5. Option E

Question 17

Given this class: And given this main method, located in another class: Which three lines, when inserted independently at line n1, cause the program to print a 0 balance? (Choose three.)

  1. acct.setAmount(-acct.getAmount());
  2. acct.amount = 0;
  3. acct.setAmount(0);
  4. acct.getAmount() = 0;
  5. this.amount = 0;
  6. acct.changeAmount(0);
  7. acct.changeAmount(-acct.amount);

Question 18

Given the code fragment: Which code fragment prints red:blue:small:medium? A. B. C. D.

Question 19

Given the code fragment: What is the result? A. B. Compilation fails only at line n1. C. Compilation fails only at line n2. D. Compilation fails only at line n3. E. Compilation fails at both line n2 and line n3.

Question 20

Given the code fragment: Which modification enables the code to print 54321?

  1. Replace line 6 with System.out. print (--x) ;
  2. At line 7, insert x --;
  3. Replace line 6 with --x; and, at line 7, insert System.out.print (x);
  4. Replace line 12 with return (x > 0) ? false: true;