QuizzesJava Concurrency: Mastering Locks and Synchronizers
intermediate
java

Java Concurrency: Mastering Locks and Synchronizers

Test your understanding of Java concurrency mechanisms focusing on locks and synchronizers.

18 minutes 12 questions Pass at 70%
Time Limit
18 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

12 questions on Java Concurrency: Mastering Locks and Synchronizers. Work through them here, then start the quiz to answer them and see your score.

  1. 1.Which class in Java provides a framework for implementing blocking locks and synchronizers?

    • AReentrantLock
    • BCountDownLatch
    • CSemaphore
    • DAbstractQueuedSynchronizer
  2. 2.What is the primary advantage of using ReentrantLock over synchronized blocks?

    • ASimpler syntax
    • BAutomatic unlocking
    • CHigher performance
    • DFairness policy
  3. 3.In Java, which method is used to release a permit from a Semaphore?

    • Arelease()
    • Bunlock()
    • Csignal()
    • Dnotify()
  4. 4.What does the await() method in CountDownLatch do?

    • ABlocks until the count reaches zero
    • BThrows an exception
    • CDecrements the count
    • DIncrements the count
  5. 5.Which of the following is true about ReadWriteLock?

    • AAllows multiple writers
    • BAllows only one reader and one writer
    • CDoes not support concurrency
    • DAllows multiple readers and one writer
  6. 6.What is the purpose of the tryLock() method in ReentrantLock?

    • ATo check if the lock is held by the current thread
    • BTo release the lock
    • CTo acquire the lock if it is free
    • DTo acquire the lock unconditionally
  7. 7.How does a CyclicBarrier differ from a CountDownLatch?

    • ACountDownLatch cannot be used for synchronization
    • BCyclicBarrier resets after use
    • CCountDownLatch resets after use
    • DCyclicBarrier is not reusable
  8. 8.Which method in ReentrantLock can be used to check if the lock is held by any thread?

    • AisHeldByCurrentThread()
    • BisFair()
    • CisReentrant()
    • DisLocked()
  9. 9.What is the main purpose of using a Phaser in Java concurrency?

    • ATo manage a fixed number of threads
    • BTo handle thread starvation
    • CTo provide a reusable synchronization barrier
    • DTo implement mutual exclusion
  10. 10.Which method in Semaphore is used to acquire multiple permits at once?

    • AacquireUninterruptibly()
    • Bacquire()
    • CacquireMultiple()
    • Dacquire(int permits)
  11. 11.What happens if a thread calls await() on a Condition object without holding the associated lock?

    • AAn IllegalMonitorStateException is thrown
    • BThe thread waits indefinitely
    • CThe thread proceeds without blocking
    • DThe thread is terminated
  12. 12.Which of the following is a feature of the Lock interface in Java?

    • AAutomatic lock release
    • BNon-reentrant locking
    • CInterruptible lock acquisition
    • DLock fairness is mandatory