Oracle Java OCP Concurrency and Multithreading Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Thames
T
Thames
Community Contributor
Quizzes Created: 11982 | Total Attempts: 187,298
| Attempts: 12 | Questions: 20 | Updated: Aug 15, 2026
Please wait...
Question 1 / 21
🏆 Rank #-- ▾
0 %
0/100
Score 0/100

1. What does an AtomicInteger provide that a regular int does not?

Explanation

`AtomicInteger` provides thread-safe operations such as incrementing and updating a value atomically, typically using compare-and-set mechanisms. These operations can be performed without adding explicit synchronization around them. A regular `int` does not guarantee that concurrent updates are atomic, so multiple threads may overwrite one another’s changes.

Submit
Please wait...
About This Quiz
Oracle Java OCP Concurrency and Multithreading Quiz - Quiz

This quiz evaluates your understanding of Java concurrency and multithreading concepts required for the OCP certification. You'll test knowledge of thread creation, synchronization, locks, concurrent collections, and thread safety patterns. Master these essential topics to build robust, multi-threaded applications and advance your Java expertise.

2.

What first name or nickname would you like us to use?

You may optionally provide this to label your report, leaderboard, or certificate.

2. Which exception is thrown if a thread is interrupted while in wait()?

Explanation

When a thread is blocked in `wait()` and another thread interrupts it, `wait()` stops waiting and throws the checked `InterruptedException`. The calling code must catch this exception or declare it in its method’s `throws` clause.

Submit

3. A synchronized method is equivalent to synchronizing on which object?

Explanation

A synchronized instance method acquires the monitor of the object on which it is called. This prevents other threads from entering synchronized instance methods on that same object until the method finishes and releases the lock. It does not lock the thread or the class object.

Submit

4. When a thread is in WAITING state, what must happen for it to progress?

Explanation

A thread in the WAITING state is paused until another thread signals it. For a thread waiting on an object monitor, another thread must call `notify()` or `notifyAll()` on that same object to allow it to become eligible to run again.

Submit

5. Which Semaphore constructor argument controls the number of permits?

Explanation

The single integer passed to the `Semaphore` constructor sets its initial number of permits, determining how many threads can acquire a permit concurrently.

Submit

6. Which method of ExecutorService waits for all submitted tasks to complete?

Explanation

`awaitTermination()` blocks until the executor has terminated after shutdown, meaning its submitted tasks have completed, or until the specified timeout expires. It returns whether termination occurred within that time.

Submit

7. Which interface must a class implement to be eligible for execution by a Thread?

Explanation

A class can be passed to a `Thread` as its task by implementing `Runnable` and defining the `run()` method, which contains the work to execute. `Callable` is typically used with executor services, while `Executor` and `ThreadFactory` serve other thread-management roles.

Submit

8. Which collection is safe for concurrent iteration without external synchronization?

Explanation

CopyOnWriteArrayList is designed for concurrent access. Its iterators traverse a snapshot of the list taken when the iterator is created, so concurrent modifications won’t disrupt iteration or cause a ConcurrentModificationException. Changes are made to a copied array, though an existing iterator won’t see those changes.

Submit

9. What is the purpose of a ReadWriteLock?

Explanation

A ReadWriteLock separates access into read and write modes. Multiple threads can hold the read lock at the same time, since they do not modify shared data. A thread holding the write lock has exclusive access, preventing reads and other writes until it releases the lock. This supports safe concurrency, especially when reads are frequent.

Submit

10. What is the result of calling notifyAll() when no threads are waiting?

Explanation

When `notifyAll()` is called while the thread holds the object’s monitor, it wakes all threads waiting on that object. If no threads are waiting, there is nobody to wake, so the call has no effect. The calling thread continues running normally.

Submit

11. A thread calls wait() on an object. Which thread can wake it with notify()?

Explanation

A thread can call `notify()` only while holding the monitor lock for that same object. It can then wake one thread waiting on that object; the awakened thread resumes only after it reacquires the lock.

Submit

12. Which class provides thread-safe operations without explicit synchronization?

Explanation

ConcurrentHashMap is designed for safe access by multiple threads, coordinating updates internally so callers do not need synchronized blocks for ordinary map operations. It allows concurrent reads and updates with less contention than synchronizing an entire map. HashMap is not thread-safe, and ArrayList is a list, not a map. Vector is synchronized, though.

Submit

13. What does the volatile keyword guarantee in Java?

Explanation

In Java, declaring a variable `volatile` ensures that a thread reading it sees the most recently written value, rather than a stale cached copy. A write to a volatile variable happens-before a subsequent read of that variable. Volatile does not provide mutual exclusion or make compound operations, such as incrementing, atomic.

Submit

14. What is the primary difference between Runnable and Callable?

Explanation

Callable’s `call()` method returns a result and can throw checked exceptions. Runnable’s `run()` method returns no value and cannot declare checked exceptions. Both can be executed using an `ExecutorService`.

Submit

15. A CountDownLatch initialized with count 3. How many times must countDown() be called?

Explanation

A `CountDownLatch` starts with the specified count, and each call to `countDown()` reduces it by one. Starting at 3, it reaches zero after three calls, allowing threads waiting on `await()` to proceed. Calls may come from one thread or several.

Submit

16. Which method transitions a thread from RUNNABLE to BLOCKED state?

Explanation

In Java, a thread that tries to enter a `synchronized` block while another thread holds its monitor cannot proceed, so it enters the BLOCKED state until the lock becomes available. By contrast, `sleep()` causes TIMED_WAITING, `wait()` without a timeout causes WAITING, and `yield()` leaves the thread RUNNABLE.

Submit

17. Which Lock interface method does NOT acquire the lock if unavailable?

Explanation

`tryLock()` attempts to acquire the lock without waiting. If another thread holds it, the method immediately returns `false`; otherwise, it acquires the lock and returns `true`. In contrast, `lock()` and `lockInterruptibly()` wait for the lock to become available.

Submit

18. What is the key difference between CountDownLatch and CyclicBarrier?

Explanation

A `CountDownLatch` is initialized with a count that decreases as events occur; once it reaches zero, it cannot be reset for another use. A `CyclicBarrier` synchronizes a fixed number of threads and can be reused after all participating threads reach it, making it suitable for repeated coordination phases.

Submit

19. What does a Phaser control that CountDownLatch and CyclicBarrier do not?

Explanation

A Phaser coordinates threads across successive synchronization phases, advancing when all registered parties arrive. Unlike CountDownLatch, which is generally one-shot, and CyclicBarrier, which repeats a fixed barrier pattern, a Phaser allows parties to register or deregister dynamically and supports flexible phase progression. This makes it suited to workflows with multiple, changing stages of coordination.

Submit

20. What does the ForkJoinPool optimize for compared to ExecutorService?

Explanation

ForkJoinPool is optimized for tasks that can be recursively split into smaller subtasks and later combined, a pattern common in divide-and-conquer algorithms. Its work-stealing mechanism lets idle worker threads take tasks from busy threads, helping keep processors utilized. General ExecutorService implementations are better suited to a broader range of task types.

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (20)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
What does an AtomicInteger provide that a regular int does not?
Which exception is thrown if a thread is interrupted while in wait()?
A synchronized method is equivalent to synchronizing on which object?
When a thread is in WAITING state, what must happen for it to...
Which Semaphore constructor argument controls the number of permits?
Which method of ExecutorService waits for all submitted tasks to...
Which interface must a class implement to be eligible for execution by...
Which collection is safe for concurrent iteration without external...
What is the purpose of a ReadWriteLock?
What is the result of calling notifyAll() when no threads are waiting?
A thread calls wait() on an object. Which thread can wake it with...
Which class provides thread-safe operations without explicit...
What does the volatile keyword guarantee in Java?
What is the primary difference between Runnable and Callable?
A CountDownLatch initialized with count 3. How many times must...
Which method transitions a thread from RUNNABLE to BLOCKED state?
Which Lock interface method does NOT acquire the lock if unavailable?
What is the key difference between CountDownLatch and CyclicBarrier?
What does a Phaser control that CountDownLatch and CyclicBarrier do...
What does the ForkJoinPool optimize for compared to ExecutorService?
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!