Home »
MCQs
Spring Multiple-Choice Questions (MCQs)
The Spring Framework is an application framework of Java. It is light-weight and supports various frameworks like struts, hibernate, tapestry, etc. Its core features can be used by any Java application.
Spring MCQs: This section contains multiple-choice questions and answers on the various topics of Spring. Practice these MCQs to test and enhance your skills on Spring.
List of Spring MCQs
1. Spring framework was released in ____.
- 2001
- 2002
- 2003
- 2005
Answer: C) 2003
Explanation:
The spring framework was released in June 2003.
Discuss this Question
2. Is Spring framework open-source?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, the Spring framework is open-source.
Discuss this Question
3. What is IOC?
- Integral of conversion
- Integrated oriented control
- Inversion of conversion
- Inversion of control
Answer: D) Inversion of control
Explanation:
IOC stands for Inversion of control.
Discuss this Question
4. IOC is also known as ____.
- Dependency injection
- Bean Factory
- Application dependency
Answer: A) Dependency injection
Explanation:
IOC is also known as Dependency injection.
Discuss this Question
5. Which of the following clearly states the role of IOC in Spring?
- To instantiate the application class
- To setup the object
- To assemble the object dependencies
- All of the above
Answer: D) All of the above
Explanation:
Following are the responsibilities of IOC in Spring:
- To instantiate the application class
- To setup the object
- To assemble the object dependencies
Discuss this Question
6. How many types of IOC containers are there?
- 5
- 4
- 3
- 2
Answer: D) 2
Explanation:
There are two types of IOC containers:
- BeanFactory
- ApplicationContext
Discuss this Question
7. Which is better to use, ApplicationContext or BeanFactory?
- BeanFactory
- ApplicationContext
Answer: B) ApplicationContext
Explanation:
The ApplicationContext interface is constructed on top of the BeanFactory interface. So, it provides more capabilities than BeanFactory, therefore it is better to use ApplicationContext than BeanFactory.
Discuss this Question
8. ____ are the objects that constitute the backbone of your application and are maintained by the Spring IoC container?
- Threads
- Process
- Beans
- Application
Answer: C) Beans
Explanation:
Beans are the objects that constitute the backbone of your application and are maintained by the Spring IoC container.
Discuss this Question
9. ____ is a design technique that eliminates dependencies from programming code to make the application easier to manage and test.
- Dependency Injection (DI)
- Dependency Lookup (DL)
- Dependency constructor (DC)
Answer: A) Dependency Injection (DI)
Explanation:
Dependency Injection (DI) is a design technique that eliminates dependencies from programming code to make the application easier to manage and test.
Discuss this Question
10. The ____ method obtains the resource after the demand
- Dependency Injection (DI)
- Dependency Lookup (DL)
- Dependency constructor (DC)
Answer: B) Dependency Lookup (DL)
Explanation:
The Dependency Lookup method obtains the resource after demand.
Discuss this Question
11. In how many ways you can inject dependency?
- 4
- 2
- 5
- 7
Answer: B) 2
Explanation:
The Spring framework provides two methods for injecting dependencies:
- By constructor
- By Setter method
Discuss this Question
12. The dependency lookup technique strongly couples the code?
- True
- False
Answer: A) True
Explanation:
Yes, The dependency lookup technique strongly couples the code, which makes it a problem to use this approach.
Discuss this Question
13. Does the Dependency Lookup technique causes several issues when testing the program, particularly in black box testing?
- Yes
- No
Answer: A) Yes
Explanation:
The Dependency Lookup technique causes several issues when testing the program, particularly in black box testing.
Discuss this Question
14. Spring framework's ____ capability allows you to insert object dependencies indirectly.
- Autowiring
- Autoreferences
- Applicationbean
- AutoBeans
Answer: A) Autowiring
Explanation:
Spring framework's autowiring capability allows you to insert object dependencies indirectly.
Discuss this Question
15. Does Autowiring requires more coding?
- Yes
- No
Answer: B) No
Explanation:
No, Autowiring needs the least amount of coding.
Discuss this Question
16. Which of the following is the default autowiring mode?
- Byname
- ByType
- No
- Constructor
Answer: C) No
Explanation:
No is the standard autowiring mode. It signifies that autowiring is off by default.
Discuss this Question
17. When using ____ autowiring mode, the bean id and reference name must be identical.
- Byname
- ByType
- No
- Constructor
Answer: A) Byname
Explanation:
When using byName autowiring mode, the bean id and reference name must be identical.
Discuss this Question
18. Which of the following scope, restricts the bean specification to a single instance per Spring IoC container?
- Singleton
- Prototype
- Session
- Global-session
Answer: A) Singleton
Explanation:
Singleton scope, restricts the bean specification to a single instance per Spring IoC container.
Discuss this Question
19. Which of the following scope allows a single bean specification to have an unlimited number of object instances?
- Singleton
- Prototype
- Session
- Global-session
Answer: B) Prototype
Explanation:
Prototype scope allows a single bean specification to have an unlimited number of object instances.
Discuss this Question
20. The scope is always ____ by default?
- Singleton
- Prototype
- Session
- Global-session
Answer: A) Singleton
Explanation:
The scope is always singleton by default.
Discuss this Question
21. Singleton scope should be used with ____.
- EJB stateless session
- EJB stateful session bean.
Answer: A) EJB stateless session
Explanation:
Singleton scope should be used with EJB stateless session bean.
Discuss this Question
22. Prototype scope should be used with ____.
- EJB stateless session
- EJB stateful session bean.
Answer: B) EJB stateful session bean.
Explanation:
Prototype scope should be used with EJB stateful session bean.
Discuss this Question
23. What is AOP?
- Aspect object programming
- Aspect-oriented programming
- Artificial-oriented programming
- Artificial object programming
Answer: B) Aspect-oriented programming
Explanation:
AOP stands for Aspect-oriented programming
Discuss this Question
24. ____ beans are defined inside the scope of another bean.
- Core
- Outer
- Peripheral
- Inner
Answer: D) Inner
Explanation:
Inner beans are defined inside the scope of another bean.
Discuss this Question
25. ____ denotes an action taken by an aspect at a specific join point.
- Interceptor
- Advice
- Pointcut
- Target Object
Answer: B) Advice
Explanation:
Advice denotes an action taken by an aspect at a specific joint point.
Discuss this Question
26. Which of the following type of advice executes before and after a joint point?
- Before advice
- After Returning Advice
- After Throwing Advice
- Around Advice
Answer: D) Around Advice
Explanation:
Around Advice is a type of advice that is executed before and after a joint point.
Discuss this Question
27. Which of the following type of advice executes if the method exits by throwing an exception?
- Before advice
- After Returning Advice
- After Throwing Advice
- Around Advice
Answer: C) After Throwing Advice
Explanation:
After throwing advice is a type of advice that is executed if the method exits by throwing an exception.
Discuss this Question
28. Which of the following type of advice executes after a joint point has been completed properly?
- Before advice
- After Returning Advice
- After Throwing Advice
- Around Advice
Answer: B) After Returning Advice
Explanation:
After Returning Advice executes after a joint point has been completed properly.
Discuss this Question
29. How many types of collection configuration element does Spring offers?
- 3
- 4
- 2
- 5
Answer: B) 4
Explanation:
Spring provides the following four types of collection configuration elements:
- <LIST>
- <MAP>
- <SET>
- <PROPS>
Discuss this Question
30. ____ aids in wiring a group of values that are not duplicated?
- <LIST>
- <MAP>
- <SET>
- <PROPS>
Answer: C) <SET>
Explanation:
<SET> aids in wiring a group of values that are not duplicated.
Discuss this Question
31. Which of the following is useful for wiring, such as injecting a list of variables and allowing for duplication?
- <LIST>
- <MAP>
- <SET>
- <PROPS>
Answer: A) <LIST>
Explanation:
<LIST> is useful for wiring, such as injecting a list of variables and allowing for duplication.
Discuss this Question
32. ____ can be employed to inject a collection of name-value pairs with any type of name and value?
- <LIST>
- <MAP>
- <SET>
- <PROPS>
Answer: B) <MAP>
Explanation:
<MAP> can be employed to inject a collection of name-value pairs with any type of name and value.
Discuss this Question
33. How many different ways may Spring-based apps be configured?
- Java-based configuration
- XML-based configuration
- Annotation-based configuration
- All of the above
Answer: D) All of the above
Explanation:
Spring-based apps be configured in the following ways:
- Java-based configuration
- XML-based configuration
- Annotation-based configuration
Discuss this Question
34. How many autowiring modes are there in Spring?
- 4
- 5
- 2
- 3
Answer: A) 4
Explanation:
There are 4 autowiring modes:
- No
- ByName
- Bytype
- Constructor
Discuss this Question
35. What are the limitations of autowiring in spring?
- Simple attributes like as primitives, Strings, and Classes cannot be autowired.
- Autowiring is not as precise as explicit wiring.
- All of the above
Answer: C) All of the above
Explanation:
Following are the disadvantages of autowiring:
- Simple attributes like as primitives, Strings, and Classes cannot be autowired.
- Autowiring is not as precise as explicit wiring.
Discuss this Question
36. ____ is a class that accepts incoming requests and routes them to the appropriate resources such as controllers, models, and views.
- DispatcherServlet
- Servlet
- ServletContext
- HandlerApapter
Answer: A) DispatcherServlet
Explanation:
DispatcherServlet is a class that accepts incoming requests and routes them to the appropriate resources such as controllers, models, and views.
Discuss this Question
37. With Spring Web MVC, which class serves as the front controller?
- DispatcherServlet
- Servlet
- ServletContext
- HandlerApapter
Answer: A) DispatcherServlet
Explanation:
The DispatcherServlet class serves as the front controller in Spring Web MVC.
Discuss this Question
38. Which annotation designates a class as the controller?
- @cont
- @controller
- @_controller
- @__controller
Answer: B) @controller
Explanation:
The @Controller annotation designates a class as the controller.
Discuss this Question
39. A ____ contains an application's business logic.
- Model
- View
- Controller
Answer: C) Controller
Explanation:
A controller contains an application's business logic.
Discuss this Question
40. We can construct only one controller in Spring MVC at the same time?
- True
- False
Answer: B) False
Explanation:
We can construct many controllers in Spring MVC at the same time.
Discuss this Question
41. In the controller class, ____ is used to read the HTML form data that the user has given.
- HttpServletRequest
- Model
- HttpModel
Answer: A) HttpServletRequest
Explanation:
HttpServletRequest is used to read the HTML form data that the user has given.
Discuss this Question
42. What are the responsibilities of JdbcTemplate class?
- Takes care of resource generation
- We can carry out all database operations.
- Handles the exception and displays useful error messages
- All of the above
Answer: D) All of the above
Explanation:
Following are the responsibilities of Jdbctemplate class:
- Takes care of resource generation
- We can carry out all database operations.
- Handles the exception and displays useful error messages
Discuss this Question
43. Using the ____ function of the JdbcTemplate class, we can simply get records from the database.
- Fetch()
- Query()
- Get()
Answer: B) Query()
Explanation:
Using the query() function of the JdbcTemplate class, we can simply get records from the database.
Discuss this Question
44. ____ is used to increase modularity by cross-cutting concerns.
- JVM
- Jdbctemplate class
- OOP
- AOP
Answer: D) AOP
Explanation:
AOP is used to increase modularity by cross-cutting concerns.
Discuss this Question
45. The ResultSetExtractor is used ____.
- To get records from a database
- To set records of a database
- None
Answer: A) To get records from a database
Explanation:
The ResultSetExtractor is used to get records from a database.
Discuss this Question
46. Which of the following helps us to fetch the record from the database?
- ResultSetExtractor
- RowMapper
- Both
- None
Answer: C) Both
Explanation:
ResultSetExtractor, and RowMapper both are used to fetch the record from the database.
Discuss this Question
47. Which of the following annotation is used to associate a URL with a whole class or a specific handler function?
- @RequestMapping
- @RequestMap
- @RequestMapper
- @Mapper
Answer: A) @RequestMapping
Explanation:
The @RequestMapping annotation is used to associate a URL with a whole class or a specific handler function.
Discuss this Question
48. Among Local and Global transactions, which is easier to implement?
- Local Transactions
- Global transactions
Answer: A) Local Transactions
Explanation:
Local transactions are easier to implement.
Discuss this Question
49. Which transaction management is required in a distributed computing environment?
- Local Transactions
- Global transactions
Answer: B) Global transactions
Explanation:
Global transaction management is required in a distributed computing environment, whereas Local transaction management is required in a centralized computing environment.
Discuss this Question
50. How many types of transaction management does spring support?
- 3
- 4
- 5
- 2
Answer: D) 2
Explanation:
Spring supports two types of transaction management:
- Programmatic transaction management
- Declarative transaction management
Discuss this Question
51. Which type of transaction management is preferred?
- Programmatic transaction management
- Declarative transaction management
Answer: B) Declarative transaction management
Explanation:
Declarative transaction management is preferred over programmatic transaction management.
Discuss this Question
52. Which type of transaction management enables you to handle transactions using programming in your source code?
- Programmatic transaction management
- Declarative transaction management
Answer: A) Programmatic transaction management
Explanation:
The programmatic transaction management solution enables you to handle transactions using programming in your source code.
Discuss this Question
53. Which type of transaction management allows you to handle transactions using configuration rather than hard-coding in your source code?
- Programmatic transaction management
- Declarative transaction management
Answer: B) Declarative transaction management
Explanation:
The declarative transaction management solution allows you to handle transactions using configuration rather than hard-coding in your source code.
Discuss this Question
54. What is DAO?
- Data-accurate object
- Data access oriented
- Data access object
Answer: C) Data access object
Explanation:
DAO stands for Data Access Object.
Discuss this Question
55. The key unit of modularity in OOP is the ____?
- Module
- Class
- Aspect
- Objects
Answer: B) Class
Explanation:
The key unit of modularity in OOP is the class.
Discuss this Question
56. The key unit of modularity in AOP is the ____?
- Module
- Class
- Aspect
- Objects
Answer: C) Aspect
Explanation:
The key unit of modularity in AOP is the Aspect.
Discuss this Question
57. Which Annotation indicates that a particular parameter, return value, or field is null?
- @null
- @nullable
- @nullify
Answer: B) @nullable
Explanation:
@nullable annotation indicates that a particular parameter, return value, or field is null.
Discuss this Question
58. ____ is the technique of connecting aspects with other types of applications.
- Weaving
- Interceptor
- Jointpoint
Answer: A) Weaving
Explanation:
Weaving is the technique of connecting aspects with other types of applications.
Discuss this Question
59. ____ is a class-like feature that just includes one piece of advice.
- Weaving
- Interceptor
- Jointpoint
Answer: B) Interceptor
Explanation:
Interceptor is a class-like feature that just includes one piece of advice.
Discuss this Question
60. SpEL stands for ____.
- Spring expression language
- Spring ejection language
- Spring ejection Locator
Answer: A) Spring expression language
Explanation:
SpEL stands for Spring expression language.
Discuss this Question