Spring Interview Questions - Javatpoint
Spring Interview Questions - Javatpoint
⇧ SCROLL TO TOP
https://www.javatpoint.com/spring-interview-questions 1/15
3/25/23, 10:39 PM Spring Interview Questions - javatpoint
1) What is Spring?
1. Predefined Templates
2. Loose Coupling
3. Easy to test
4. Lightweight
5. Fast Development
6. Powerful Abstraction
7. Declarative support
More details...
3) What are the modules of spring framework?
1. Test
2. Spring Core Container
3. AOP, Aspects and Instrumentation
4. Data Access/Integration
5. Web
More details...
4) What is IOC and DI?
IOC (Inversion of Control) and DI (Dependency Injection) is a design pattern to provide loose
coupling. It removes the dependency from the program.
Let's write a code without following IOC and DI.
https://www.javatpoint.com/spring-interview-questions 2/15
3/25/23, 10:39 PM Spring Interview Questions - javatpoint
public class Employee{
Address address;
Employee(){
address=new Address();//creating instance
}
}
Now, there is dependency between Employee and Address because Employee is forced to use
the same address instance.
Let's write the IOC or DI code.
public class Employee{
Address address;
Employee(Address address){
this.address=address;//not creating instance
}
}
Now, there is no dependency between Employee and Address because Employee is not forced to
use the same address instance. It can use any address instance.
#1 Software development
course
Newton School
Get placement assistance with Newton
School's Placement Portal.
my.newtonschool.co
OPEN
https://www.javatpoint.com/spring-interview-questions 4/15
3/25/23, 10:39 PM Spring Interview Questions - javatpoint
3) Creates new instance if any Doesn't create new instance if you change the
modification occurs property value
4) Better for too many properties Better for few properties.
More details...
9) What is autowiring in spring? What are the autowiring modes?
Autowiring enables the programmer to inject the bean automatically. We don't need to write
explicit injection logic.
Let's see the code to inject bean using dependency injection.
<bean id="emp" class="com.javatpoint.Employee" autowire="byName" />
1) singleton The bean instance will be only once and same instance will be returned
by the IOC container. It is the default scope.
2) prototype The bean instance will be created each time when requested.
https://www.javatpoint.com/spring-interview-questions 5/15
3/25/23, 10:39 PM Spring Interview Questions - javatpoint
11) In which scenario, you will use singleton and prototype scope?
Singleton scope should be used with EJB stateless session bean and prototype scope with EJB
stateful session bean.
Less code: By using the JdbcTemplate class, you don't need to create
connection,statement,start transaction,commit transaction and close connection to execute
different queries. You can execute the query directly.
More details...
https://www.javatpoint.com/spring-interview-questions 6/15
3/25/23, 10:39 PM Spring Interview Questions - javatpoint
1. JdbcTemplate
2. SimpleJdbcTemplate
3. NamedParameterJdbcTemplate
4. SimpleJdbcInsert
5. SimpleJdbcCall
More details...
15) How can you fetch records by spring JdbcTemplate?
You can fetch records from the database by the query method of JdbcTemplate. There are two
interfaces to do this:
1. ResultSetExtractor
2. RowMapper
It is better to remember.
More details...
17) What is the advantage of SimpleJdbcTemplate?
AOP is an acronym for Aspect Oriented Programming. It is a methodology that divides the
program logic into pieces or parts or concerns.
https://www.javatpoint.com/spring-interview-questions 7/15
3/25/23, 10:39 PM Spring Interview Questions - javatpoint
AOP enables you to dynamically add or remove concern before or after the business logic. It is
pluggable and easy to maintain.
More details...
20) What are the AOP terminology?
JoinPoint is any point in your program such as field access, method execution, exception handling
etc.
https://www.javatpoint.com/spring-interview-questions 8/15
3/25/23, 10:39 PM Spring Interview Questions - javatpoint
Advertisement
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.
https://www.javatpoint.com/spring-interview-questions 10/15
3/25/23, 10:39 PM Spring Interview Questions - javatpoint
Yes.
https://www.javatpoint.com/spring-interview-questions 12/15
3/25/23, 10:39 PM Spring Interview Questions - javatpoint
Preparation
Company
Interview
Questions
Company Questions
Trending Technologies
https://www.javatpoint.com/spring-interview-questions 13/15
3/25/23, 10:39 PM Spring Interview Questions - javatpoint
B.Tech / MCA
https://www.javatpoint.com/spring-interview-questions 14/15
3/25/23, 10:39 PM Spring Interview Questions - javatpoint
https://www.javatpoint.com/spring-interview-questions 15/15