Interview Questions: Spring IoC Container

June 11, 2013
Qns-1: Which packages is the basis of Spring IoC container?
Ans: a. org.springframework.beans b. org.springframework.context
Qns-2: What is the role of BeanFactory in Spring IoC container?
Ans: BeanFactory provides the configuration mechanism so that any type of object can be managed easily.
Qns-3: What is the role of ApplicationContext in Spring IoC container?
Ans: ApplicationContext extends BeanFactory. ApplicationContext helps to integrate other module like Spring AOP, messages resource , event publication, application-layer specific contexts.
Qns-4: How can we instantiate ApplicationContext in standalone application?
Ans: We need to call ClassPathXmlApplicationContext or FileSystemXmlApplicationContext.
Qns-5: What are the variants of dependency Injection?
Ans: There are two variants of Dependency Injection.
a. Constructor-based dependency injection
b. Setter-based dependency injection
Qns-6: What are disadvantages of autowiring in Spring?
Ans: a. We cannot autowire primitives dat type, String and Classes.
b. Autowiring is not so exact as explicit wiring.
c. Autowiring will not be available for those tools that will generate documentation.
Qns-7: How many beans scopes are there in Spring IoC Container?
Ans: There are five Bean scopes.
a. Singleton
b. Prototype
c. Request
d. Session
e. Global Session
Qns-8: How to customize the nature of a bean?
Ans: a. Lifecycle callbacks can be customized by implementing interface InitializingBean and DisposableBean.
b. Startup and shutdown callbacks can be customized by implementing interface Lifecycle.
c. Use ApplicationContextAware and BeanNameAware.
Qns-9: What is the role of BeanPostProcessor Interface?
Ans: Implementing BeanPostProcessor interface, we can write our own bean instantiation logic.
Qns-10: What is the role of PropertyPlaceholderConfigurer in spring?
Ans: PropertyPlaceholderConfigurer externalize property values from a bean definition to another separate file.
LEARN MORE








©2024 concretepage.com | Privacy Policy | Contact Us