Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.
Concurrency & Parallelism (Intro)Easy
Q1. What is concurrency in programming?
- A.Running only one task at a time sequentially
- B.Handling multiple tasks in overlapping time periods✓ Correct
- C.Exactly the same concept as true parallelism
- D.Strictly sequential execution of all operations
Explanation
Concurrency is the ability to manage multiple tasks that can start, run, and complete in overlapping time periods.
Report an error in this question
Concurrency & Parallelism (Intro)Easy
Q2. What is a thread?
- A.A reusable function definition block
- B.A type of string data structure
- C.The smallest unit of execution within a process✓ Correct
- D.A data structure for storing elements
Explanation
A thread is the smallest sequence of instructions that can be managed independently by a scheduler.
Report an error in this question
Concurrency & Parallelism (Intro)Easy
Q3. What is a race condition?
- A.A debugging tool for analyzing multi-threaded applications
- B.A bug where outcome depends on non-deterministic thread timing✓ Correct
- C.A performance competition between different threads
- D.A type of exception thrown during concurrent data access
Explanation
A race condition occurs when multiple threads access shared data concurrently and the result depends on execution order.
Report an error in this question
Concurrency & Parallelism (Intro)Easy
Q4. What is a process?
- A.A function call that executes and then returns
- B.An independent program with its own memory space✓ Correct
- C.A variable that stores data during execution
- D.The same thing as a thread in all respects
Explanation
A process is an independent program in execution with its own memory space.
Report an error in this question
Concurrency & Parallelism (Intro)Easy
Q5. What is the main benefit of concurrency?
- A.Improved performance and responsiveness of programs✓ Correct
- B.Simpler code that is easier to read and understand
- C.Smaller program binaries with reduced memory footprint
- D.Fewer bugs and errors during program execution overall
Explanation
Concurrency improves performance by overlapping I/O with computation and keeps the UI responsive.
Report an error in this question
Concurrency & Parallelism (Intro)Easy
Q6. What is multithreading?
- A.A type of recursion with multiple recursive calls
- B.Using multiple programming languages in one project
- C.Using multiple processors in a distributed system
- D.Running multiple threads within a single process✓ Correct
Explanation
Multithreading is the execution of multiple threads within a single process, sharing the same memory space.
Report an error in this question
Concurrency & Parallelism (Intro)Easy
Q7. What is the difference between concurrency and parallelism?
- A.Concurrency always requires multiple CPU cores to function properly
- B.Parallelism is always slower than concurrency in every scenario
- C.They are exactly the same concept with no differences at all
- D.Concurrency manages overlapping tasks; parallelism runs simultaneously✓ Correct
Explanation
Concurrency is about dealing with multiple tasks at once (structure); parallelism is about executing multiple tasks simultaneously (execution).
Report an error in this question
Concurrency & Parallelism (Intro)Easy
Q8. What is a mutex?
- A.An algorithm for sorting elements in a collection
- B.A primitive data type for storing values
- C.A lock ensuring exclusive resource access for one thread✓ Correct
- D.A function for performing calculations on data values
Explanation
A mutex prevents multiple threads from simultaneously accessing a shared resource.
Report an error in this question
Concurrency & Parallelism (Intro)Easy
Q9. What is a deadlock?
- A.A memory leak from unreleased dynamically allocated data
- B.A type of infinite loop caused by incorrect conditions
- C.Threads blocked forever waiting for each other resources✓ Correct
- D.A program crash caused by a runtime error in code
Explanation
A deadlock occurs when threads are blocked indefinitely because each holds a resource the other needs.
Report an error in this question
Concurrency & Parallelism (Intro)Easy
Q10. What is synchronization?
- A.A file operation for reading and writing data safely
- B.Running code statements in sequential order always
- C.A network protocol for data transfer between systems
- D.Coordinating shared resource access to prevent races✓ Correct
Explanation
Synchronization coordinates thread access to shared resources to prevent race conditions.
Report an error in this question
Concurrency & Parallelism (Intro)Medium
Q11. What is the volatile keyword in Java?
- A.A final variable that cannot be modified after assignment
- B.A keyword ensuring reads always come from main memory✓ Correct
- C.A variable that changes randomly without any cause
- D.A type of exception thrown during concurrent operations
Explanation
volatile ensures reads and writes go directly to main memory, preventing thread-local caching.
Report an error in this question
Concurrency & Parallelism (Intro)Medium
Q12. What is async/await?
- A.A type of loop for iterating over collection elements
- B.A testing pattern for validating asynchronous behavior
- C.A syntax for writing async code that looks synchronous✓ Correct
- D.A threading model for managing parallel execution of tasks
Explanation
async/await is syntactic sugar for working with promises/futures, allowing asynchronous code to be written sequentially.
Report an error in this question
Concurrency & Parallelism (Intro)Medium
Q13. What is an atomic operation?
- A.An indivisible operation completing without interruption✓ Correct
- B.A nuclear physics operation on atomic particles
- C.A file operation that reads and writes data to disk
- D.A database transaction that groups multiple queries
Explanation
An atomic operation is indivisible: it either completes entirely or not at all, preventing race conditions.
Report an error in this question
Concurrency & Parallelism (Intro)Medium
Q14. What is thread safety?
- A.A testing concept for validating thread performance
- B.Code functioning correctly under multi-thread access✓ Correct
- C.A debugging feature for analyzing thread behavior
- D.Threads that are guaranteed to never crash or fail
Explanation
Thread-safe code produces correct results when accessed by multiple threads concurrently.
Report an error in this question
Concurrency & Parallelism (Intro)Medium
Q15. What is context switching?
- A.Saving one thread state and loading another for CPU switching✓ Correct
- B.Changing the scope of a variable from local to global
- C.Changing between different programming languages in a project
- D.Switching between different source code files in an editor
Explanation
Context switching saves the current thread's state and restores another's when the CPU switches execution.
Report an error in this question
Concurrency & Parallelism (Intro)Medium
Q16. What is the dining philosophers problem?
- A.A sorting problem for ordering elements in a collection
- B.A classic problem illustrating resource allocation and deadlock✓ Correct
- C.A database problem with concurrent transaction conflicts
- D.A food-related algorithm for meal planning optimization
Explanation
The dining philosophers problem demonstrates deadlock and resource contention with shared resources.
Report an error in this question
Concurrency & Parallelism (Intro)Medium
Q17. What is the producer-consumer problem?
- A.A database issue with concurrent read and write transaction conflicts
- B.A business problem related to supply chain management
- C.A network problem caused by packet loss during data transmission
- D.A synchronization problem with shared buffer between producers and consumers✓ Correct
Explanation
The producer-consumer problem involves synchronizing producers and consumers sharing a bounded buffer.
Report an error in this question
Concurrency & Parallelism (Intro)Medium
Q18. What is a Future/Promise?
- A.An object representing a value available in the future✓ Correct
- B.A type of thread that executes tasks asynchronously
- C.A variable that is declared for use at a later time
- D.A timer that triggers a callback after a set delay
Explanation
A Future/Promise is a placeholder for a result that hasn't been computed yet.
Report an error in this question
Concurrency & Parallelism (Intro)Hard
Q19. What is the difference between optimistic and pessimistic concurrency control?
- A.There is no meaningful difference between the two control approaches
- B.Pessimistic concurrency control never uses any locks on resources
- C.Optimistic concurrency control uses locks to prevent all conflicts
- D.Optimistic assumes no conflicts and validates; pessimistic locks first✓ Correct
Explanation
Optimistic allows concurrent access and checks at commit. Pessimistic locks resources before access.
Report an error in this question
Concurrency & Parallelism (Intro)Medium
Q20. What is a thread pool?
- A.Pre-created worker threads reused for tasks✓ Correct
- B.A memory pool for thread-local storage data
- C.A collection of all threads in the system
- D.A connection pool for database access threads
Explanation
A thread pool maintains reusable threads that pick up tasks from a queue, reducing thread creation overhead.
Report an error in this question
Concurrency & Parallelism (Intro)Medium
Q21. What is a semaphore?
- A.A counter-based primitive controlling shared resource access✓ Correct
- B.A thread type for running background tasks in parallel
- C.A simple flag variable for boolean state tracking
- D.A type of lock for exclusive thread synchronization
Explanation
A semaphore maintains a count representing available resources; threads acquire (decrement) or release (increment) it.
Report an error in this question
Concurrency & Parallelism (Intro)Hard
Q22. What is the Java Memory Model (JMM)?
- A.A memory leak detector for finding unreleased allocations
- B.A garbage collection model for reclaiming unused object memory
- C.A specification defining thread memory interaction and visibility✓ Correct
- D.How Java manages memory allocation for objects on the heap
Explanation
The JMM defines rules for thread interaction through shared memory, including visibility guarantees.
Report an error in this question
Concurrency & Parallelism (Intro)Hard
Q23. What is work stealing in thread pool implementations?
- A.A security vulnerability where threads access unauthorized data
- B.Interrupting running threads to reassign their execution priority
- C.Idle threads stealing tasks from busy threads for load balancing✓ Correct
- D.Taking another thread source code and executing it directly
Explanation
Work stealing lets idle threads take tasks from busy threads' queues, dynamically balancing workload.
Report an error in this question
Concurrency & Parallelism (Intro)Hard
Q24. What is the Compare-and-Swap (CAS) operation?
- A.A file swap operation for exchanging file contents
- B.A string operation for replacing character subsequences
- C.A sorting operation for ordering elements in arrays
- D.An atomic operation comparing and swapping memory values✓ Correct
Explanation
CAS atomically checks if a memory location holds an expected value and replaces it if it does.
Report an error in this question
Concurrency & Parallelism (Intro)Hard
Q25. What is lock-free programming?
- A.A type of race condition caused by missing synchronization
- B.Programming without any synchronization mechanisms at all
- C.Single-threaded programming without any concurrent access
- D.Using atomic operations instead of locks for thread progress✓ Correct
Explanation
Lock-free programming uses atomic operations to ensure at least one thread always makes progress.
Report an error in this question
Concurrency & Parallelism (Intro)Hard
Q26. What is the difference between green threads and OS threads?
- A.Green threads are runtime-scheduled; OS threads are kernel-managed✓ Correct
- B.Green threads are always faster than OS threads in every scenario
- C.They are exactly the same with no meaningful differences at all
- D.OS threads use less memory than green threads in all situations
Explanation
Green threads are scheduled by the language runtime. OS threads are kernel-managed with true parallelism but higher overhead.
Report an error in this question
Concurrency & Parallelism (Intro)Hard
Q27. What is the happens-before relationship in concurrency?
- A.A scheduling algorithm for determining thread execution priority
- B.Simple chronological ordering of events by their timestamps
- C.A debugging concept for tracing the order of function calls
- D.A guarantee that writes by one action are visible to another✓ Correct
Explanation
Happens-before guarantees that memory effects of one operation are visible to another.
Report an error in this question
Concurrency & Parallelism (Intro)Hard
Q28. What is a read-write lock (ReentrantReadWriteLock)?
- A.A file lock for preventing concurrent file access
- B.A database lock for serializing transaction execution
- C.A lock allowing multiple readers but exclusive writers✓ Correct
- D.A mutex variant supporting recursive lock acquisition
Explanation
A read-write lock allows multiple readers simultaneously but requires exclusive access for writing.
Report an error in this question
Concurrency & Parallelism (Intro)Hard
Q29. What is a memory barrier/fence?
- A.A hardware instruction enforcing memory operation ordering for CPUs✓ Correct
- B.A memory protection boundary between user and kernel space
- C.A memory limit restricting maximum allocation size for processes
- D.A garbage collection trigger that starts when memory is low
Explanation
A memory barrier prevents the CPU from reordering memory operations across it, ensuring visibility.
Report an error in this question
Concurrency & Parallelism (Intro)Hard
Q30. What is Software Transactional Memory (STM)?
- A.A concurrency mechanism using transactions for shared memory with retry✓ Correct
- B.A memory allocation strategy for managing heap memory efficiently
- C.A thread scheduler for determining execution order of all threads
- D.A relational database system for persistent data storage
Explanation
STM treats shared memory operations as transactions that can be composed, committed atomically, or retried on conflict.
Report an error in this question