Oracle
1Z0-804 · Question #88
Given: import java.util.concurrent.atomic.AtomicInteger; public class AtomicCounter { private AtomicInteger c = new AtomicInteger(0); public void increment() { // insert code here } } Which line of…
Sign in or unlock 1Z0-804 to reveal the answer and full explanation for question #88. The question stem and answer options stay visible for context.
Concurrency
Question
Given:
import java.util.concurrent.atomic.AtomicInteger; public class AtomicCounter { private AtomicInteger c = new AtomicInteger(0); public void increment() { // insert code here } } Which line of code, inserted inside the increment () method, will increment the value of c?
Options
- AC.addAndGet();
- Bc++;
- Cc = c+1;
- DC.getAndIncrement ();
Unlock 1Z0-804 to see the answer
You've previewed enough free 1Z0-804 questions. Unlock 1Z0-804 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
#AtomicInteger#getAndIncrement#atomic operations#thread-safe increment