Test Series - spring

Test Number 4/20

Q: Method used to process bean before initialization callback
A. scope
B. postProcessAfterInitialization()
C. postProcessBeforeInitialization()
D. it’s own constructor
Solution: You can process every bean before initialization callback method by implementing the postProcessBeforeInitialization() and methods.
Q: Method used to process bean after initialization callback
A. scope
B. getBean
C. postProcessAfterInitialization()
D. it’s own constructor
Solution: You can process every bean after initialization callback method by implementing the postProcessAfterInitialization() and methods.
Q: Which method is used to gracefully shutdown all the bean processes after closing the spring container?
A. shutdownHook
B. destroy method
C. none of the mentioned
D. all of the mentioned
Solution: ShutdownHook method gracefully shuts down each bean process before closing the container.
Q: Which method is used to register BeanPostProcessor?
A. addBeanPostProcessors
B. registerBeanPostProcessors
C. addBeanProcessors
D. none of the mentioned
Solution: When using a bean factory as your IoC container, bean post processors can only be registered programmatically, or more accurately, via the addBeanPostProcessor() method.
Q: Which Interface for bean Post Processor is used to distinguish between checked beans
A. StorageConfig
B. Marker
C. None of the mentioned
D. All of the mentioned
Solution: First of all, for the bean post processor to distinguish which beans should be checked, you create a marker interface, StorageConfig, for your target beans to implement.
Q: Which method of bean post processors is used to check path existence
A. getPath
B. setPath
C. value
D. auto-wiring
Solution: Moreover, for your bean post processor to check for path existence, it must be able to access the path property. This can be done by adding the getPath() method to this interface.
Q: PathCheckingBeanPostProcessor will not work properly in case of:-
A. XML Configuration
B. Java based Configuration
C. JSR Annotation
D. None of the mentioned
Solution: This is because your bean post processor has a lower priority than CommonAnnotationBeanPostProcessor by default. As a result, the initialization method will be called before your path checking.
Q: Which bean factory post processor externalizes part of the bean configurations into a properties file
A. PropertyPlaceholderConfigurer
B. PropertyPlaceholderRegister
C. PropertyGetPath
D. None of the mentioned
Solution: Spring comes with a bean factory post processor called PropertyPlaceholderConfigurer for you to externalize part of the bean configurations into a properties file.
Q: Which interface defines methods for resolving text messages
A. MessageSource
B. ApplicationListener
C. ApplicationContextListener
D. TextEvent
Solution: MessageSource is an interface that defines several methods for resolving messages.
Q: Which interface is used to listen to certain events
A. ApplicationListener
B. ContextListener
C. EventListener
D. None of the mentioned
Solution: For a bean to listen to certain events, it must implement the ApplicationListener interface and handle the events in the onApplicationEvent() method.

You Have Score    /10