Loading

Quipoin Menu

Learn • Practice • Grow

python / Threading and Multiprocessing
mcq
Direction: Choose the correct option

Q1.

What is the difference between threading and multiprocessing in Python?
A. Threads share memory, processes have separate memory
B. Threads are faster
C. Both A and B
D. Threads are for I/O, processes for CPU
Direction: Choose the correct option

Q2.

What is the Global Interpreter Lock (GIL)?
A. A lock for multiprocessing
B. A lock that allows only one thread to execute Python bytecode at a time
C. A memory lock
D. A threading lock
Direction: Choose the correct option

Q3.

Which module provides threading support?
A. All of the above
B. concurrent.futures
C. threading
D. multiprocessing
Direction: Choose the correct option

Q4.

How do you start a thread?
A. t = Thread(target=func); t.start()
B. t = Thread(target=func); t.run()
C. t = threading.Thread(target=func); t.start()
D. t = threading.Thread(target=func); t.start()
Direction: Choose the correct option

Q5.

What is a daemon thread?
A. A thread for I/O
B. A thread that runs forever
C. A high-priority thread
D. A thread that runs in background and exits when main program exits
Direction: Choose the correct option

Q6.

How do you wait for a thread to finish?
A. t.sync()
B. t.wait()
C. t.complete()
D. t.join()
Direction: Choose the correct option

Q7.

What is a Process in the multiprocessing module?
A. A module
B. A lightweight thread
C. A separate system process with its own memory
D. A function
Direction: Choose the correct option

Q8.

How do you create a process pool?
A. from multiprocessing import ProcessPool
B. ProcessPool(4)
C. multiprocessing.pool()
D. from multiprocessing import Pool; pool = Pool(processes=4)
Direction: Choose the correct option

Q9.

What is the purpose of `queue.Queue` in threading?
A. A data structure
C. Thread-safe communication between threads
D. Queue for multiprocessing
Direction: Choose the correct option

Q10.

What does `concurrent.futures` provide?
A. Both A and B
C. A high-level interface for asynchronously executing callables
D. Thread and process pools