Question 1
What is the primary advantage of using a thread pool in Java?
It allows for better thread prioritization
It reuses threads to minimize the overhead of creating new ones
It makes the program run faster
It can prevent thread starvation
Question 2
Which of the following classes is used to create a thread pool in Java?
Executor
ExecutorService
ThreadPoolExecutor
All of the above
Question 3
What is the default priority of a thread in Java?
1
5
10
0
Question 4
Which method is used to set the priority of a thread in Java?
setPriority()
changePriority()
setThreadPriority()
updatePriority()
Question 5
What happens if a thread has a higher priority than other threads in the same pool?
It will always execute before lower-priority threads
It will execute only after all lower-priority threads finish
It may execute before lower-priority threads, but it is not guaranteed
It will be suspended
Question 6
What is the purpose of the Executors class in Java?
To manage threads manually
To provide methods for creating thread pools
To handle thread synchronization
To terminate all threads at once
Question 7
Which of the following thread pool types does Executors.newFixedThreadPool() create?
A pool with a fixed number of threads
A pool that creates threads as needed
A pool that never reuses threads
A pool with unlimited threads
Question 8
Which of the following is true about the ThreadPoolExecutor class?
It is a direct implementation of the Executor interface
It creates a new thread for each task execution
It provides more control over the behavior of the thread pool
It is deprecated
Question 9
Which method is used to submit tasks to an executor in Java?
submit()
add()
execute()
run()
Question 10
What is the result of using an unbounded thread pool?
It can lead to out-of-memory errors if too many threads are created
It will always result in thread starvation
It provides faster execution of tasks
None of the above
There are 10 questions to complete.