Learn. Practice. Feel prepared.
Spring Objective Questions and Answers - Set 2
Test and improve your knowledge of the Spring Framework with expertly curated MCQs covering IoC, Dependency Injection, Bean lifecycle, annotations, AOP, Spring JDBC, transactions, and Spring MVC. Perfect for Spring interviews, backend developers, and Java professionals aiming to strengthen their framework fundamentals. This is part 2 of the series.
Practice Spring MCQs with Detailed Explanations
Answer at least 12 questions to submit and verify answers.
16 Which of the following is correct about dependency injection? A - It helps in decoupling application objects from each other. B - It helps in deciding the dependencies of objects. C - It stores objects states in database. D - It stores object states in file system.
Correct answer:
A
17 What is Advice?
Correct answer:
This is the actual action to be taken either before or after the method execution.
18 What is a DispatcherServlet?
Correct answer:
DispatcherServlet handles all the HTTP requests and responses.
19 What are the ways to access Hibernate by using Spring?
Correct answer:
Both of above.
20 What is global-session scope?
Correct answer:
This scopes a bean definition to an HTTP Application/ Global session.
21 Which of the among is not a special bean in WebApplicationContext?
Correct answer:
None of the above
22 What could not return a Spring MVC controller ?
Correct answer:
null value
23 Where do you cannot declare Spring MVC controller? A. In a Spring application context XML configuration file B. Into the web.xml file of the web application C. Into the java code by using annotations D. Into the JSP pages
Correct answer:
B,D
24 How the spring DispatcherServlet supports for returning the last-modification-date ,as specified by Servlet API?
Correct answer:
By implementing the LastModified interface
25 Which of these statement is false regarding the given handlerMappings?
Correct answer:
<strong>SimpleUrlHandlerMapping</strong> — Maps request to controller and controller methods that are annotated with @RequestMapping.
26 Which handlerMappings are being used by default if no handlerMapping beans are found?
Correct answer:
DefaultAnnotationHandlerMapping
27 Which is not a view in Spring Web Flow?
Correct answer:
Start
28 What is ContextStartedEvent event?
Correct answer:
The event is published when ApplicationContext is started using the start method on the Configurable ApplicationContext interface
29 Which is not a MethodNameResolver ?
Correct answer:
XMLMethodNameResolver
30 How could you externalize constants from a Spring configuration file or a Spring annotation into a .properties file?
Correct answer:
By using the <context:property-placeholder /> tag