nerdexam
Oracle

1Z0-819 · Question #52

1Z0-819 Question #52: Real Exam Question with Answer & Explanation

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

Question

Given public class Foo { private final ReentrantLock lock = new ReentrantLock(); private State state; public void foo() throws Exception { try { lock.lock(); state.mutate(); } finally { lock.unlock(); } } } What is required to make the Foo class thread safe?

Options

  • ANo change is required;
  • BMake the declaration of lock static.
  • CReplace the constructor call with new ReentrantLock (true).
  • DMove the declaration of lock inside the foo method.

Unlock 1Z0-819 to see the answer

You've previewed enough free 1Z0-819 questions. Unlock 1Z0-819 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.

Full 1Z0-819 Practice