Question 1
When is a method annotated @PreDestroy invoked for a singleton bean?
A. During container shutdown, just before the bean is destroyedCorrect answer
Correct: @PreDestroy is a JSR-250 destruction callback the container runs as it closes, just before a singleton is disposed, making it the place to release resources (Spring Framework 5.3 Reference, @PostConstruct and @PreDestroy).
B. Immediately after @PostConstruct completes
Confuses the two lifecycle ends: @PostConstruct runs after initialization while @PreDestroy runs at teardown, so they are not chained back-to-back.
C. Never for singletons; only prototypes get @PreDestroy
Exactly reversed: singletons do receive the callback at container shutdown, whereas prototype beans are the ones that get no destruction callbacks at all since the container does not manage their full lifecycle.
D. After every method invocation on the bean
It is a one-time teardown hook, not a per-invocation interceptor; the method fires once as the bean is destroyed, not after each call.
Explanation
@PreDestroy is a one-time JSR-250 teardown callback that the container runs as it closes, just before a managed singleton is disposed, which is why it is used to release resources. It is tied to destruction rather than to initialization or per-method invocation, and it is singletons — not prototypes — that receive it.