Spring Interview Questions
1. What is Spring
framework?
Spring is development framework for
Java programming. It is an open source development framework for Enterprise
Java. The core features of Spring Framework can be used in developing a Java
Enterprise application. It has many extensions and jars for developing web
applications on top of Java EE platform. With Spring we can develop large-scale
complex Java applications very easily. It is also based on good design patterns
like Dependency Injection, Aspect oriented programming for developing
extensible feature rich software.
2. What are the
benefits of Spring framework in software development?
Many benefits of Spring framework are:
Lightweight Framework: Basic Spring framework is very small in size. It is easy to use and
does not add a lot of overhead on software. It just has 2 MB in basic version.
Container:
Spring framework provides the basic container that creates and manages the life
cycle of application objects like Plain old Java objects (POJO). It also stores
the configuration files of application objects to be created.
Dependency Injection (DI): Spring provided loose coupling is application by Dependency
Injection. It uses Inversion of Control technique by which objects specify
their dependencies to Spring container instead of creating new objects
themselves.
Aspect Oriented Programming (AOP): Spring framework promotes and provides support for Aspect
oriented programming in Java. This helps in separating application business
logic from system services that are common across all the business logic. E.g.
Logging can be a cross cutting concern in an Application.
Transaction Management: Spring provides a framework for transaction management. So
a developer does not have to implement it from scratch. Spring Transaction
Management is so powerful that we can scale it from one local transaction to
global transactions in a cluster.
MVC Framework:
For Web applications, Spring provides MVC framework. This framework is based on
MVC design pattern and has better features compared to other web frameworks. Exception
Handling: Spring also gives support for a common API to handle exceptions in
various technologies like- Hibernate, JDBC etc.
Exception Handling: Spring also gives support for a common API to handle exceptions in
various technologies like- Hibernate, JDBC etc.
3. What are the modules
in Core Container of Spring framework?
Spring framework has a Core Container. Modules in Core
Container are:
Core module
Bean module
Context module
Spring Expression Language module
4. What are the modules
in Data Access/Integration layer of Spring framework?
Modules in Data Access/Integration Layer of Spring framework
are:
JDBC module:
An abstraction layer to remove tedious JDBC coding. ORM module Integration
layers for Object Relational Mapping
OXM module: An
abstraction layer to support Object XML mapping.
Java Messaging Service (JMS) module: Module for producing and consuming messages.
Transactions module: Transaction Management for POJO classes
5. What are the modules
in Web layer of Spring framework?
Modules in Web Layer of Spring framework are:
Web module:
This provides basic web-oriented integration features.
Servlet module:
Support for Servlet Listeners.
WebSocket module: Support for Web Socket style messaging.
Portlet module:
MVC implementation for Portlet environment.
5.What is the main use
of Core Container module in Spring framework?
As the name suggests, Spring Core
Container is the core of Spring framework. It gives the basic functionality of
the Spring. All the parts of Spring Framework are built on top of Core
Container. Its main use is to provide Dependency Injection (DI) and Inversion of
control (IOC) features.
6. What kind of testing can be done in Spring Test Module?
Spring Test Module provides support
for Unit testing as well as Integration testing of Spring components. It allows
using JUnit or TestNG testing frameworks. It also gives ability to mock objects
to use the test code.
7. What is the use of BeanFactory in Spring framework?
BeanFactory is the main class that
helps in implementing Inversion of Control pattern in Spring. It is based on
the factory design pattern. It separates the configuration and dependencies of
an application from the rest of application code. Implementations of
BeanFactory like XmlBeanFactory class are used by applications built with
Spring.
8. Which is the most popular implementation of BeanFactory in
Spring?
XMLBeanFactory is the most popular
implementation of BeanFactory in Spring.
9. What is XMLBeanFactory in Spring framework?
XMLBeanFactory is one of the most
useful implementation of BeanFactory in Spring. This factory loads its beans
based on the definitions mentioned in an XML file.
Spring container reads bean
configuration metadata from an XML file and creates a fully configured
application with the help of XMLBeanFactory class.
10. What are the uses of AOP module in Spring framework?
AOP module is also known as Aspect
Oriented Programming module. Its uses are:
Development of aspects in a Spring
based application Provides inter-operability between Spring and other AOP frameworks
Supports metadata programming to Spring
11. What are the benefits of JDBC abstraction layer module in
Spring framework?
Spring provides JDBC abstraction
layer module. Main benefits of this module are:
Helps in keeping the database code
clean and simple. Prevents problems that result from a failure to close
database resources. Provides a layer of useful exceptions on top of the error
messages given by different database servers. Based on Spring’s AOP module Provides transaction management services for
objects in a Spring Application
12. How does Spring support Object Relational Mapping (ORM) integration?
Spring supports Object Relational
Mapping (ORM) by providing ORM Module. This module helps in integrating with
popular ORM framework like Hibernate, JDO, and iBATIS SQL Maps etc.
Transaction Management module of
Spring framework supports all of these ORM frameworks as well as JDBC.
13. How does Web module work in Spring framework?
Spring provides support for developing
web application by using Web module. This module is built on application
context module that provides context for web-based applications.
This module also supports
web-oriented integration features like-transparently handling multi-part requests
for uploading files, pro-grammatically binding request parameters to business
objects etc.
This module also supports integration
with popular web frameworks like Jakarta Struts, JSF, and Tapestry etc.
Comments