38. What is Web-Servlet module in Spring?
The Web Struts module supports integration of struts into a Spring application. However, this support is deprecated as of Spring 3.0.
- Injecting dependencies via setter methods.
- Injecting dependencies via constructor
42. How ambiguities among constructor arguments can be dealt in injecting dependencies?
It can be dealt in two ways:
- By index
- By type
43. How Spring application is different from Java application?
The difference lies in how these classes are configured and introduced to each other. Typically a Spring application has an XML file that tells how to configure the classes, known as Spring configuration file.
44. How can we inject prototype bean into singleton in Spring?
It can be done in two ways. They are
- Method injection using lookup-method property
- AOP scoped proxy
45. What is method injection using lookup-method?
Suppose we want to inject prototype bean into singleton bean then we have to use method injection like this:
<bean id="prototype" class="com.a4academics.Prototype" scope="prototype" />
<bean id="singleton" class="com.a4academics.Singleton">
<lookup-method name="createPrototype" bean="prototype" />
Here Singleton class has reference to Prototype class and createPrototype() is a method.
46. What is loose coupling and tight coupling code?
Loose coupling is one of the critical elements in object oriented software development. It allows you to change the implementations of two related objects without affecting the other object. Strong coupling directly affects scalability of an application. Tightly coupled code is difficult to test, reuse and understand.
47. How we can reduce coupling?
One way to reduce coupling is to hide implementation details behind interfaces, so that actual implementation class can be swapped out without impacting the client class.
48. What is the core of Spring's DI container?
49. What are the different Inversion Of Control (IOC) approaches?
- Type1: Interface injection
- Type2: Setter injection
- Type3: Constructor injection
50. What is the scope of Spring bean by default?
51. What is singleton bean?
Singleton beans are created only once by the container and all calls to BeanFactory.getBean() return the same instance.
52. What is prototype bean?
Prototype bean lets the container return a new instance, each time a bean is asked for.