🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Java Concurrency Utilities: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. Why can two threads running count++ on a shared int lose updates?
  2. Q2. What does this print? (code)
  3. Q3. What does compare-and-set (CAS) do?
  4. Q4. Which call counts a word in a ConcurrentHashMap safely from many threads?
  5. Q5. What does this print? (code)
  6. Q6. A CountDownLatch is created with count 3. When does await() return?
  7. Q7. You want at most 3 threads to use the database at the same time. Which tool fits?
  8. Q8. What does this print? (code)
  9. Q9. In a CompletableFuture chain, a stage throws an exception. What happens to the next thenApply?
  10. Q10. What is the main advantage of ConcurrentHashMap over a HashMap wrapped in synchronized blocks?