Spring Interview Questions and Answers

    0 Votes

38. What is Web-Servlet module in Spring?

The Web-Servlet module is Spring's model view controller(MVC) implementation for web applications. Spring's MVC framework separates domain model code and web forms. It also helps application to integrate with all the other features of the Spring framework.
39. What is Web-Struts 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.

40. What is Test module in Spring?
The Spring Test module can test Spring components with Junit or TestNG. It provides the consistent loading of Spring Application Context and caching of those context. It also provides mock objects that you can use to test your code in isolation.
41. What are the ways to inject dependencies in Spring?
  • 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" />
</bean>

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?

BeanFactory

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?

Singleton scope

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.

Page 4 of 5

Popular Videos

communication

How to improve your Interview, Salary Negotiation, Communication & Presentation Skills.

Got a tip or Question?
Let us know

Related Articles

JSP Interview Questions and Answers
Servlet Interview Questions and Answers
Advanced Servlet Interview Questions and Answers
EJB Interview Questions and Answers