@PostConstruct is executed?The @PostConstruct method runs once the bean is fully created and all dependencies are injected. It is used to perform initialization tasks before the bean is used.
@PreDestroy executed?The @PreDestroy method runs just before the bean is destroyed by the Spring container. It is used to release resources or perform cleanup.
@PostConstruct in a Spring Boot component?The @PostConstruct method must be void, have no parameters, and not be static. Option C meets all these requirements.
cleanup method never be called when the application stops?If a class is not registered as a Spring bean (e.g., missing @Component), Spring does not manage its lifecycle, so @PreDestroy methods won't be called.
@PostConstruct, what will happen when the bean is initialized?Spring calls all methods annotated with @PostConstruct in a bean, but the order is not guaranteed. Both methods will run during initialization.
