Skip to main content

Spring Interview Questions


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

Popular posts from this blog

DOCKER Interview questions

DOCKER 1. What is Docker? Docker is Open Source software. It provides the automation of Linux application deployment in a software container. We can do operating system level virtualization on Linux with Docker. Docker can package software in a complete file system that contains software code, runtime environment, system tools, & libraries that are required to install and run the software on a server. 2. What is the difference between Docker image and Docker container? Docker container is simply an instance of Docker image. A Docker image is an immutable file, which is a snapshot of container. We create an image with build command. When we use run command, an Image will produce a container. In programming language, an Image is a Class and a Container is an instance of the class. 3. How will you remove an image from Docker? We can use docker rmi command to delete an image from our local system. Exact command is: % docker rmi <Image Id> If we want to fin...

Cloud Computing Interview Questions

Cloud Computing 1. What are the benefits of Cloud Computing? There are ten main benefits of Cloud Computing: Flexibility : The businesses that have fluctuating bandwidth demands need the flexibility of Cloud Computing. If you need high bandwidth, you can scale up your cloud capacity. When you do not need high bandwidth, you can just scale down. There is no need to be tied into an inflexible fixed capacity infrastructure. Disaster Recovery : Cloud Computing provides robust backup and recovery solutions that are hosted in cloud. Due to this there is no need to spend extra resources on homegrown disaster recovery. It also saves time in setting up disaster recovery. Automatic Software Updates : Most of the Cloud providers give automatic software updates. This reduces the extra task of installing new software version and always catching up with the latest software installs. Low Capital Expenditure : In Cloud computing the model is Pay as you Go. This means there is very...

Microservices Interview Questions

Microservices Interview Questions 1. What is a Microservice in Java? A Microservice is a small and autonomous piece of code that does one thing very well. It is focused on doing well one specific task in a big system. It is also an autonomous entity that can be designed, developed and deployed independently. Generally, it is implemented as a REST service on HTTP protocol, with technology-agnostic APIs. Ideally, it does not share database with any other service. 2. What are the benefits of Microservices architecture? Microservices provide many benefits. Some of the key benefits are: 1.      Scaling : Since there are multiple Microservices instead of one monolith, it is easier to scale up the service that is being used more. Eg. Let say, you have a Product Lookup service and Product Buy service. The frequency of Product Lookup is much higher than Product Buy service. In this case, you can just scale up the Product Lookup service to run on powerful ha...