2V0-72.22PSE · Question #49
Spring puts each bean instance in a scope. What is the default scope? (Choose the best answer.)
The correct answer is B. singleton. Singleton is Spring's default scope because the IoC container creates exactly one instance of a bean per application context, and all requests for that bean return the same shared instance. Prototype (A) is the opposite - it creates a new instance every time the bean is…
Question
Spring puts each bean instance in a scope. What is the default scope? (Choose the best answer.)
Options
- Aprototype
- Bsingleton
- Crequest
- Dsession
How the community answered
(69 responses)- A1% (1)
- B90% (62)
- C3% (2)
- D6% (4)
Explanation
Singleton is Spring's default scope because the IoC container creates exactly one instance of a bean per application context, and all requests for that bean return the same shared instance. Prototype (A) is the opposite - it creates a new instance every time the bean is requested, which must be explicitly declared. Request (C) and Session (D) are web-aware scopes tied to HTTP request and session lifecycles respectively, and only make sense in a web application context.
Memory tip: Think "Spring is a singleton club by default" - one bean, one instance, shared everywhere, unless you opt out.
Topics
Community Discussion
No community discussion yet for this question.