Question 1
What is the output of the following program? ```java import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class Main { public static void main(String[] args) { ExecutorService ex = Executors.newSingleThreadExecutor(); ex.shutdown(); System.out.println(ex.isShutdown()); } } ```
A. trueCorrect answer
Correct: shutdown flips isShutdown to true right away.
B. An exception is thrown because no task was ever submitted
An empty executor shuts down without complaint; no task submission is required.
C. false
isShutdown reflects that shutdown was called, so it is true; whether all work has finished is a separate state.
D. The program never exits because shutdown blocks
shutdown returns immediately without blocking.
Explanation
isShutdown becomes true immediately once shutdown is called, meaning no new tasks are accepted rather than that all work has finished. shutdown does not block, and an executor with no submitted tasks shuts down normally.