Spring Framework Interview Questions

What is Spring Framework?
Spring is an open source development framework for enterprise Java. The core features of the Spring Framework can be used in developing any Java application, but there are extensions for building web applications on top of the Java EE platform. Spring framework targets to make J2EE development easier to use and promote good programming practice by enabling a POJO-based programming model.

What is IOC or inversion of control?
This Spring interview question is first step towards Spring framework and many interviewer starts Spring interview from this question. As the name implies Inversion of control means now we have inverted the control of creating the object from our own using new operator to container or framework. Now it’s the responsibility of container to create object as required. We maintain one xml file where we configure our components, services, all the classes and their property. We just need to mention which service is needed by which component and container will create the object for us. This concept is known as dependency injection because all object dependency (resources) is injected into it by framework.

What is the core container module?
This module is provided by the fundamental functionality of the spring framework. In this module BeanFactory is the heart of any spring-based application. The entire framework has been built atop this module. This module is what we call the core container module.

What is spring configuration file?
Spring configuration file is an XML file. The file contains the information of the classes and describes how this classes are configured and introduced to each other.

Give an example of BeanFactory implementation?
Ans. The most common example of BeanFactory implementation is the XmlBeanFactory class. This container contains reads the configuration metadata from an Xml file and uses it to create a fully configured system or application.

Name the different types of Autowire types?
There are four different types of Autowire, they are:

Spring interview Questions for fresher’s:

What is default scope of bean in Spring framework?

What are the different types of IOC (dependency injection) ?
Constructor InjectionDependencies are provided as constructor parameters.
Setter Injection Dependencies are assigned through JavaBeans properties (ex: setter methods).
Interface Injection Injection is done through an interface.
Spring Framework supports only Constructor and Setter Injection

What are the main benefits or advantages of Spring Framework?
Spring Framework is Comparatively light weight container in comparison to other J2EE containers.
Spring Framework provides services like transaction control, AOP management, JDBC interaction.
Spring Helps in creating loosely coupled applications.
Spring Framework is not dependent on any Application servers.
Through aspect oriented programming logging, transaction, security etc. set of activities can be easily managed.
Supports for data access techniques such as DAO, JDBC, Hibernate, IBATIS, JDO etc.
Spring configuration is done in standard XML format which easy to write and understand.

what are the modules in Spring framework?
Core container: BeanFactory, an implementation of the Factory pattern is an essential component of core container. The BeanFactory applies the Inversion of Control (IOC) pattern to separate an application’s configuration and dependency specification from the actual application code.
Spring context: Spring context comprise of configuration file that provides context information to the Spring framework. The Spring context includes enterprise services such as internalization, validation, JNDI, and scheduling functionality.
Spring AOP: Spring AOP module integrates aspect-oriented programming functionality directly into the Spring framework, through its configuration management feature. Through AOP services like transaction control, logging etc can be easily managed.
Spring DAO: Spring DAO makes it easy to work with relational database management systems on the Java platform using JDBC and object-relational mapping tools. Spring JDBC DAO abstraction layer offers a meaningful exception hierarchy for managing the exception handling and error messages thrown by different database vendors. The exception hierarchy simplifies error handling and greatly reduces the amount of exception code you need to write, such as opening and closing connections.
Spring ORM: The Spring framework plugs into several ORM frameworks to provide its Object Relational tool, including JDO, Hibernate, and iBatis SQL Maps.
Spring Web module: Built on top of the application context module, providing contexts for Web-based applications. As a result, the Spring framework supports integration with Jakarta Struts. The Web module also eases the tasks of handling multi-part requests and binding request parameters to domain objects.
Spring MVC framework: Model-View-Controller (MVC) framework is a full-featured MVC implementation for building Web applications. The MVC framework is highly configurable via strategy interfaces and assembles various view technologies including JSP, Tiles, iText, and POI.

What is XmlBeanFactory ?
XmlBeanFactory class is one of the many implementations of BeanFactory interface. This implementation helps to define your application objects and dependencies between such objects, in terms of XML format. XmlBeanFactory extends DefaultListableBeanFactory and defines two constructors.

Leave a Reply

Your email address will not be published. Required fields are marked *

Play CAPTCHA Audio
Reload Image