- Spring - Home
- Spring - Overview
- Spring - Architecture
- Spring - Environment Setup
- Spring - Hello World Example
- Spring - IoC Containers
- Spring - Bean Definition
- Spring - Bean Scopes
- Spring - Bean Life Cycle
- Spring - Bean Post Processors
- Spring - Bean Definition Inheritance
- Spring - Dependency Injection
- Spring - Injecting Inner Beans
- Spring - Injecting Collection
- Spring - Beans Auto-Wiring
- Annotation Based Configuration
- Spring - Java Based Configuration
- Spring - Event Handling in Spring
- Spring - Custom Events in Spring
- Spring - AOP with Spring Framework
- Spring - JDBC Framework
- Spring - Transaction Management
- Spring - Web MVC Framework
- Spring - Logging with Log4J
Spring Useful Resources
Spring Online Quiz
Following quiz provides Multiple Choice Questions (MCQs) related to Spring Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.
Q 1 - 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.
Answer : A
Explanation
Dependency injection helps in decoupling application objects from each other.
Q 2 - What is singleton scope?
A - This scopes the bean definition to a single instance per Spring IoC container.
B - This scopes the bean definition to a single instance per HTTP Request.
C - This scopes the bean definition to a single instance per HTTP Session.
D - This scopes the bean definition to a single instance per HTTP Application/ Global session.
Answer : A
Explanation
singleton scope instructs Spring IoC container to create a single instance per IoC container.
Q 3 - What is default scope of bean in Spring framework?
Answer : A
Explanation
singleton is the default scope of any spring bean.
Q 4 - How do you turn on annotation wiring?
A - Add <annotation-context:config /> to bean configuration.
B - Add <annotation-config /> to bean configuration.
C - Add <annotation-context-config /> to bean configuration.
Answer : D
Explanation
Add <context:annotation-config/> to bean configuration to turn on annotation wiring.
Q 5 - What is ContextStoppedEvent event?
A - This event is published when the Servlet Context is either initialized or refreshed.
C - This event is published when the HTTP Request is received.
D - This event is published when the HTTP Response is returned.
Answer : B
Explanation
This event is published when the ApplicationContext is stopped using the stop() method on the ConfigurableApplicationContext interface.
Q 6 - How before advice works?
A - Run advice before a class loads.
B - Run advice before a method execution.
Answer : B
Explanation
before advice runs before a method execution.
Q 7 - What are the ways to access Hibernate by using Spring?
A - Inversion of Control with a Hibernate Template and Callback.
B - Extending HibernateDAOSupport and Applying an AOP Interceptor node.
Answer : C
Explanation
Hibernate can be accessed by both ways either using Inversion of Control with a Hibernate Template and Callback or extending HibernateDAOSupport and applying an AOP Interceptor node.
Q 8 - Which class acts as IoC Container?
Answer : C
Explanation
ApplicationContext class acts as IoC Container.
Answer : B
Explanation
Id is not a mandatory attribute in beans configuration file.
Q 10 - Which of the following class can be used to execute Sql queries in spring?
Answer : B
Explanation
JdbcTemplate class can be used to execute Sql queries in spring.