PRACTICE • LEARN • GROW
Module 10 Final Quiz: Multithreading & Concurrency MCQs
Solve topic-wise placement questions and improve your skills.
Module 10 Final Quiz: Multithreading & Concurrency Progress
0 of 12 completed
0%
Topic Track
You are viewing MCQs in preview mode. Log in to select options, submit answers, and track your progress.
Log In to Answer
1
Which header file provides the std::thread class in modern C++ (C++11 onwards)?
A.
B.
C.
D.
Explanation & Key
Correct Answer:
2
What happens if a std::thread object is destroyed while still joinable (without calling join() or detach())?
A.
The thread pauses execution
B.
std::terminate() is called immediately, crashing the entire process
C.
The thread is detached automatically
D.
The thread becomes a daemon process
Explanation & Key
Correct Answer:
3
What does calling 't.join()' on a std::thread do?
A.
Terminates thread t immediately
B.
Blocks the calling thread until thread t finishes its execution
C.
Merges two threads into one
D.
Suspends the thread for 1 second
Explanation & Key
Correct Answer:
4
What is a Race Condition in multithreaded C++?
A.
Two threads competing to run on the fastest CPU core
B.
When two or more concurrent threads access shared memory simultaneously and at least one modifies it without synchronization, producing unpredictable corrupted results
C.
A compilation benchmark test
D.
A thread that finishes faster than main()
Explanation & Key
Correct Answer:
5
What synchronization primitive ensures that only one thread can access a critical section at a time?
A.
std::atomic_flag
B.
std::mutex (Mutual Exclusion lock)
C.
std::barrier
D.
std::future
Explanation & Key
Correct Answer:
6
What catastrophic bug can occur if a thread calls mtx.lock() but an exception is thrown before mtx.unlock() is reached?
A.
Memory leak
B.
Deadlock: the mutex remains permanently locked, freezing all other threads waiting for that mutex
C.
Segmentation fault
D.
CPU clock underclocking
Explanation & Key
Correct Answer:
7
Why is 'std::lock_guard lock(mtx);' preferred over manual mtx.lock() and mtx.unlock()?
A.
It runs faster than a mutex
B.
It follows RAII: it locks on construction and automatically unlocks upon destruction (even if an exception is thrown)
C.
It allows multiple threads to write simultaneously
D.
It works without including
Explanation & Key
Correct Answer:
8
What is the difference between std::lock_guard and std::unique_lock?
A.
unique_lock is older than lock_guard
B.
std::unique_lock provides more flexibility (can be manually unlocked, deferred, moved, and used with condition_variables) with slight overhead
C.
lock_guard can only be used on Windows
D.
unique_lock does not use a mutex
Explanation & Key
Correct Answer:
9
What synchronization tool allows a thread to sleep and wait until another thread signals that work is ready?
A.
std::condition_variable
B.
std::chrono::sleep
C.
std::spin_lock
D.
std::semaphore
Explanation & Key
Correct Answer:
10
What is the purpose of std::atomic types (like std::atomic) in C++?
A.
They prevent radiation damage to RAM
B.
They allow lock-free, thread-safe atomic operations on simple variables without the heavy overhead of a mutex
C.
They only work inside GPU shaders
D.
They allow storing floating point numbers in char arrays
Explanation & Key
Correct Answer:
11
What is a Deadlock in concurrent programming?
A.
A thread running too slowly
B.
A situation where two or more threads are permanently blocked, each waiting for a lock held by the other
C.
A program terminating before all threads join
D.
CPU operating temperature exceeding limits
Explanation & Key
Correct Answer:
12
How can you launch a thread with a lambda expression in C++?
A.
thread t([]() { cout << "Hi"; });
B.
thread t = lambda();
C.
run_thread([]() {});
D.
thread.start([]() {});
Explanation & Key
Correct Answer:
Question Palette
Answered
Current
Not Attempted
Wrong