Oracle
1Z0-851 · Question #220
1Z0-851 Question #220: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-851 to reveal the answer and full explanation for question #220. The question stem and answer options stay visible for context.
Question
Given: public class TestSeven extends Thread { private static int x; public synchronized void doThings() { int current = x; current++; x = current; } public void run() { doThings(); } } Which statement is true?
Options
- ACompilation fails.
- BAn exception is thrown at runtime.
- CSynchronizing the run() method would make the class thread-safe.
- DThe data in variable "x" are protected from concurrent access problems.
- EDeclaring the doThings() method as static would make the class thread-safe.
- FWrapping the statements within doThings() in a synchronized(new Object()) { } block would make
Unlock 1Z0-851 to see the answer
You've previewed enough free 1Z0-851 questions. Unlock 1Z0-851 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.