Question 1
What is the purpose of the Executor framework in Java?
To manage thread execution
To define thread priorities
To perform thread synchronization
To manage thread-safe collections
Question 2
What is the main reason a race condition occurs in Java?
Multiple threads accessing read-only data
Multiple threads accessing shared mutable data without synchronization
A single thread performing non-atomic operations
Using synchronized blocks
Question 3
What is the output of the unhandled race condition example (expected vs actual)?
Always 2000
Always less than 2000
Sometimes 2000, sometimes less
Always 0
Question 4
Which race condition occurs when a thread checks a condition but another thread changes it before the action?
Read-Modify-Write Race
Initialization Race
Check-Then-Act Race
Data Visibility Race
Question 5
Which of the following is a key benefit of using the ExecutorService?
It automatically synchronizes all tasks
It provides better performance by controlling the number of threads
It allows only one thread to execute at a time
It guarantees the order of task execution
Question 6
What does the Callable interface allow you to do in Java?
Return a result from a task
Run multiple tasks concurrently
Execute a task without returning a result
None of these
Question 7
What is a potential consequence of a deadlock in Java?
Threads wait indefinitely and do not proceed with execution
Threads run faster than usual
Threads can execute without interruption
Threads are killed automatically
Question 8
Which method is used to submit tasks to an ExecutorService in Java?
submit()
execute()
addTask()
run()
Question 9
Which of the following describes a deadlock situation in Java multithreading?
When threads are not given enough CPU time
When two threads are blocked forever, each waiting for the other
When one thread keeps waiting for user input
When threads stop responding to external signals
Question 10
Which of the following is true about the Future interface in Java?
It allows you to retrieve the result of a task executed by an ExecutorService
It is used to manage thread priorities
It manages thread synchronization
It prevents race conditions
There are 13 questions to complete.