🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Java Multithreading: all 10 questions

Quiz: Java Multithreading · Question 8 of 10

What does marking a field volatile guarantee?

What does marking a field volatile guarantee?

  1. A.That count++ on it is atomic
  2. B.That every thread sees the latest written value
  3. C.That only one thread can use it at a time
  4. D.That it can never be changed
Answer & explanation

Correct answer: That every thread sees the latest written value

volatile gives visibility, not atomicity. For a safe counter, use AtomicInteger or synchronized.

Can you get the rest right without peeking?

Take the timed Quiz: Java Multithreading quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →