Learn. Practice. Feel prepared.
Java Multithreading Objective Questions and Answers
Test your skills in Java multithreading with carefully curated objective questions including output-based MCQs. Ideal for interview preparation and mastering concurrency concepts such as synchronization, executors, locks, atomic variables, deadlocks, and performance tuning.
Practice Java Multithreading MCQs with Detailed Explanations
Answer at least 12 questions to submit and verify answers.
1 Which statement about Thread.start() is correct? Easy
Correct answer:
It creates a new OS thread and then calls run()
start() creates a new thread of execution and internally calls run() on that new thread. Calling run() directly does not create a new thread.
2 What is the effect of calling Thread.sleep(0)? Medium
Correct answer:
The thread yields execution to other threads of same priority
sleep(0) is often treated as a hint to the scheduler to yield execution, allowing other runnable threads of same priority to run.
3 Which of the following guarantees visibility across threads without locking? Medium
Correct answer:
volatile
volatile guarantees visibility of writes across threads but does not provide atomicity for compound operations.
4 What happens if wait() is called without owning the object's monitor? Medium
Correct answer:
IllegalMonitorStateException is thrown
wait() must be called while holding the object's monitor; otherwise, IllegalMonitorStateException is thrown.
5 Which ExecutorService is best suited for short-lived asynchronous tasks? Medium
Correct answer:
newCachedThreadPool()
newCachedThreadPool() dynamically creates threads and reuses idle threads, making it suitable for short-lived asynchronous tasks.
6 Which situation can cause a deadlock? Medium
Correct answer:
Two threads holding locks in opposite order
Deadlock can occur when two threads acquire locks in opposite order and each waits for the other to release.
7 Which class provides atomic operations without synchronization? Medium
Correct answer:
AtomicInteger
AtomicInteger provides lock-free, thread-safe atomic operations.
8 What is the main benefit of using LongAdder over AtomicLong? High
Correct answer:
Better performance under high contention
LongAdder reduces contention by maintaining multiple counters internally, improving performance under heavy contention.
9 What state is a thread in after calling wait()? Medium
Correct answer:
WAITING
wait() causes the thread to enter WAITING state until notified.
10 Which method ensures all previously submitted tasks are completed before returning? Medium
Correct answer:
awaitTermination()
awaitTermination() blocks until tasks complete or timeout occurs after shutdown.
11 Which is true about synchronized blocks? Medium
Correct answer:
They lock a specific monitor object
synchronized blocks lock on a specific monitor object, providing fine-grained locking.
12 What does ThreadLocal provide? Medium
Correct answer:
Thread-confined variables
ThreadLocal provides variables that are local to each thread, preventing shared-state issues.
13 Which is NOT a benefit of using Executors? Medium
Correct answer:
Guaranteed task execution order across multiple threads
Executors do not guarantee execution order across multiple threads unless a single-thread executor is used.
14 What happens if a thread throws an unchecked exception? Medium
Correct answer:
The thread dies and exception is sent to uncaught handler
An unchecked exception terminates the thread and is passed to the UncaughtExceptionHandler.
15 Which mechanism supports fairness in locking? High
Correct answer:
ReentrantLock(true)
ReentrantLock can be constructed with fairness policy to reduce thread starvation.