
- Spring Core Basics
- 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 Questions and Answers
- Spring - Questions and Answers
- Spring Useful Resources
- Spring - Quick Guide
- Spring - Useful Resources
- Spring - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Spring Mock Test
This section presents you various set of Mock Tests related to Spring Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

Spring Mock Test II
Q 1 - How can you inject Java Collection in Spring?
A - Using list, set, map or props tag.
B - Using lit, set, map or collection tag.
Answer : A
Explanation
Spring supports list, set, map or props tags to inject java collections.
Q 2 - What is true about <list> collection configuration elements?
A - This helps in wiring a list of values, allowing duplicates.
B - This helps in wiring a list of values but without any duplicates.
Answer : A
Explanation
<list> tag is used to wire a list of values, allowing duplicates.
Q 3 - What is true about <set> collection configuration elements?
A - This helps in wiring a list of values, allowing duplicates.
B - This helps in wiring a list of values but without any duplicates.
Answer : B
Explanation
<set> tag is used to wire a list of values, but without any duplicates.
Q 4 - What is true about <map> collection configuration elements?
A - This helps in wiring a list of values, allowing duplicates.
B - This helps in wiring a list of values but without any duplicates.
Answer : C
Explanation
<map> tag is used to inject a collection of name-value pairs where name and value can be of any type.
Q 5 - What is true about <props> collection configuration elements?
A - This helps in wiring a list of values, allowing duplicates.
B - This helps in wiring a list of values but without any duplicates.
Answer : A
Explanation
<props> tag is used to inject a collection of name-value pairs where name and value are both Strings.
Q 6 - What is bean autowiring?
B - Autowiring injects values in spring beans.
C - Autowiring injects one bean into another.
D - Autowiring helps in wiring a list of values, allowing duplicates.
Answer : A
Explanation
Using Bean autowiring, Spring resolve collaborators (other beans) for your bean by inspecting the contents of the BeanFactory without using <constructor-arg> and <property> elements..
Q 7 - Which are the different modes of autowiring?
A - no, byName, byType, constructor, autodetect
B - no, byName, byType, constructor, autocorrect
Answer : A
Explanation
Autowiring modes are five: no, byName, byType, constructor, autodetect.
Q 8 - What is no mode of autowiring?
A - Default setting which means no autowiring and you should use explicit bean reference for wiring.
B - Autowiring by property name.
D - Similar to byType, but type applies to constructor arguments.
Answer : A
Explanation
no mode of autowiring is the default mode which means no autowiring and you should use explicit bean reference for wiring.
Q 9 - What is byName mode of autowiring?
A - Default setting which means no autowiring and you should use explicit bean reference for wiring.
D - Similar to byType, but type applies to constructor arguments.
Answer : B
Explanation
byName mode of autowiring is autowiring by property name. Spring tries to match and wire its properties with the beans defined by the same names in the configuration file.
Q 10 - What is byType mode of autowiring?
A - Default setting which meas no autowiring and you should use explicit bean reference for wiring.
Answer : D
Explanation
byType mode of autowiring is autowiring by property type. Spring tries to match and wire a property if its type matches with exactly one of the beans name in configuration file.
Q 11 - What is constructor mode of autowiring?
Answer : D
Explanation
Constructor mode of autowiring is similar to byType, but type applies to constructor arguments. If there is not exactly one bean of the constructor argument type in the container, a fatal error is raised.
Q 12 - What is autodetect mode of autowiring?
Answer : C
Explanation
In autodetect mode of autowiring spring first tries to wire using autowire by constructor, if it does not work, Spring tries to autowire by byType.
Answer : A
Explanation
null and empty string values can be injected in spring beans.
Q 14 - 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 15 - What does @Required annotation mean?
A - This annotation indicates that bean property must be populated by the user.
B - This annotation indicates that bean property is required while saving the bean data to database.
D - This annotation indicates that bean property is required while serializing the bean.
Answer : C
Explanation
@Required annotation simply indicates that the affected bean property must be populated at configuration time, through an explicit property value in a bean definition or through autowiring.
Q 16 - What is true about @Autowired annotation?
A - The @Autowired annotation can be used to autowire bean on the setter method.
Answer : B
Explanation
@Autowired annotation provides more fine-grained control over where and how autowiring should be accomplished.
Q 17 - What is ContextRefreshedEvent event?
A - This event is published when the Servlet Context is either initialized or refreshed.
B - This event is published when the HTTP Request is received.
C - This event is published when the HTTP Response is returned.
D - This event is published when the ApplicationContext is either initialized or refreshed.
Answer : D
Explanation
ContextRefreshedEvent event is published when the ApplicationContext is either initialized or refreshed.
Q 18 - What is ContextStartedEvent event?
A - This event is published when the Servlet Context is either initialized or refreshed.
B - This event is published when the HTTP Request is received.
D - This event is published when the HTTP Response is returned.
Answer : C
Explanation
ContextStartedEvent event is published when the ApplicationContext is started using the start() method on the ConfigurableApplicationContext interface.
Q 19 - 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 20 - What is ContextClosedEvent event?
A - This event is published when the Servlet Context is either initialized or refreshed.
B - This event is published when the HTTP Request is received.
C - This event is published when the HTTP Response is returned.
Answer : D
Explanation
This event is published when the ApplicationContext is closed using the close() method on the ConfigurableApplicationContext interface.
Q 21 - What is RequestHandledEvent:event?
A - This event is published when the Servlet Context is either initialized or refreshed.
B - This event is published when the HTTP Request is received.
C - This event is published when the HTTP session is initialized or refreshed.
D - This event is published when the HTTP Request is serviced.
Answer : C
Explanation
RequestHandledEvent event is published when the HTTP session is initialized or refreshed.
Q 22 - What is aspect?
A - Aspect is a way to do the dependency injection.
B - A module which has a set of APIs providing cross-cutting requirements.
C - Aspect is used to log information of application.
D - Aspect represents properties of spring based application.
Answer : B
Explanation
aspect module has a set of APIs to provide cross-cutting requirements.
Q 23 - What is Join point?
A - This represents a point in your application which joins two objects.
B - This represents a point in your object where you join values.
C - This represents a point in your object where you join injected values.
D - This represents a point in your application where you can plug-in AOP aspect.
Answer : D
Explanation
Join point represents a point in your application where you can plug-in AOP aspect.
Q 24 - What is Advice?
A - This is the way to instruct object to behave in certain manner.
B - This is used to inject values in objects.
C - This is the actual action to be taken either before or after the method execution.
D - This is not invoked during program execution by Spring AOP framework.
Answer : C
Explanation
Advice is the actual action to be taken either before or after the method execution.
Q 25 - What is Pointcut?
A - This represents a point in your application where you can plug-in AOP aspect.
B - This is a set of one or more joinpoints where an advice should be executed.
C - This is used to inject values in objects.
D - This is invoked during program execution by Spring AOP framework.
Answer : B
Explanation
Pointcut is a set of one or more joinpoints where an advice should be executed.
Answer Sheet
Question Number | Answer Key |
---|---|
1 | A |
2 | A |
3 | B |
4 | C |
5 | D |
6 | A |
7 | A |
8 | A |
9 | B |
10 | D |
11 | D |
12 | C |
13 | A |
14 | D |
15 | C |
16 | B |
17 | D |
18 | C |
19 | B |
20 | D |
21 | C |
22 | B |
23 | D |
24 | C |
25 | B |