nerdexam
Broadcom-VMware

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…

Core Spring

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)
  • A
    1% (1)
  • B
    90% (62)
  • C
    3% (2)
  • D
    6% (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

#bean-scopes#singleton#Spring-defaults#container-management

Community Discussion

No community discussion yet for this question.

Full 2V0-72.22PSE Practice