1z0-819 Practice Test

1z0-819 Practice Test practice questions, page 8 of 9, with answer review and explanations.

Question 36

Given: What is the result?

  1. The compilation fails.
  2. [0). D, | 1). i, | 2). a]
  3. [). o, | 1). a, | 2).]
  4. [0). o, | 1). i, | 2). r]
  5. ArrayIndexOutOfBounds Exception is thrown at runtime.

Question 37

Given: What is the result?

  1. An exception is thrown at runtime.
  2. -3
  3. -2
  4. The compilation fails.

Question 38

Given the code fragment: You must make the count variable thread safe. Which two modifications meet your requirement? (Choose two.)

  1. replace line 2 with public static synchronized void main(String[] args) {
  2. replace line 1 with private volatile int count = 0;
  3. replace line 3 with synchronized(test) { test.count++; }
  4. replace line 1 with private AtomicInteger count = new AtomicInteger(0); and replace line 3 with test.count.incrementAndGet();
  5. replace line 3 with synchronized(test.count) { test.count++; }

Question 39

Given the code fragment: Which action enables Computator class to compile?

  1. change Line 1 to add throws NumberFormatException
  2. change Line 3 to Double sum = 0.0;
  3. change Line 5 to List<Double> numbers = List.of(5, 4, 6, 3, 7, 2, 8, 1, 9);
  4. change Line 2 to public Double sum ( C collection) {
  5. change Line 4 to for (Double n : collection) {

Question 40

Given the code fragment: What is the result?

  1. The compilation fails due to an error in line 2.
  2. 201
  3. de
  4. 203
  5. The compilation fails due to an error in line 3.
  6. The compilation fails due to an error in line 1.