I have tried to collect some top spring core interview questions which you face into your next technical interview. For other spring modules, I will share interview questions and answers separately. I will really appreciate if you can suggest more similar interview questions which you have faced in your previous interviews and you consider them best spring interview questions to be asked. I will add them in this list. This will be great help for fellow learners as well.
Spring is a lightweight system. It can be considered as a system of structures in light of the fact that it gives backing to different structures, for example, Struts, Hibernate, Tapestry, EJB, JSF and so forth.
Lightweight: Spring is lightweight when it comes to size and transparency. The basic version of spring framework is around 2MB.
Inversion of control (IOC): Loose coupling is achieved in Spring, with the Inversion of Control technique. The objects give their dependencies instead of creating or looking for dependent objects.
Aspect oriented (AOP): Spring supports Aspect oriented programming and separates application business logic from system services.
Container: Spring contains and manages the life cycle and configuration of application objects.
MVC Framework: Spring's web framework is a well-designed web MVC framework, which provides a great alternative to web frameworks.
Transaction Management: Spring provides a consistent transaction management interface that can scale down to a local transaction and scale up to global transactions (JTA).
Exception Handling: Spring provides a convenient API to translate technology-specific exceptions (thrown by JDBC, Hibernate, or JDO) into consistent, unchecked exceptions.
The basic modules of the Spring framework are :
This is the basic Spring module, which provides the fundamental functionality of the Spring framework. BeanFactory is the heart of any spring-based application. Spring framework was built on the top of this module, which makes the Spring container.
JoinPoint is any point in your program such as field access, method execution, exception handling etc.
No, spring framework supports method execution joinpoint only.
Advice represents action taken by aspect.
There are 5 types of advices in spring AOP.
Pointcut is expression language of Spring AOP.
Aspect is a class in spring AOP that contains advices and joinpoints.
Introduction represents introduction of new fields and methods for a type.
Target Object is a proxy object that is advised by one or more aspects.
Interceptor is a class like aspect that contains one advice only.
Weaving is a process of linking aspect with other application.
No, spring framework performs weaving at runtime.
There are 3 AOP implementation.
The @Controller annotation marks the class as controller class. It is applied on the class.
The @RequestMapping annotation maps the request with the method. It is applied on the method.
The View Resolver class resolves the view component to be invoked for the request. It defines prefix and suffix properties to resolve the view component.
The org.springframework.web.servlet.view.InternalResourceViewResolver class is widely used.
Dependency Injection, an aspect of Inversion of Control (IoC), is a general concept, and it can be expressed in many different ways.This concept says that you do not create your objects but describe how they should be created. You don't directly connect your components and services together in code but describe which services are needed by which components in a configuration file. A container (the IOC container) is then responsible for hooking it all up.