Bird
0
0

Why does Spring prefer to manage Beans as singletons by default?

hard📝 Conceptual Q10 of 15
Spring Boot - Inversion of Control and Dependency Injection
Why does Spring prefer to manage Beans as singletons by default?
ATo improve performance by reusing the same instance
BTo force developers to write stateless code
CBecause prototype scope is deprecated
DTo avoid memory leaks caused by multiple instances
Step-by-Step Solution
Solution:
  1. Step 1: Understand default Bean scope rationale

    Singleton scope improves performance by reusing one instance instead of creating many.
  2. Step 2: Evaluate other options

    Singleton does not force stateless code, prototype is not deprecated, and memory leaks depend on usage, not scope.
  3. Final Answer:

    To improve performance by reusing the same instance -> Option A
  4. Quick Check:

    Singleton default = performance optimization [OK]
Quick Trick: Singleton Beans improve performance by reuse [OK]
Common Mistakes:
  • Thinking prototype scope is deprecated
  • Believing singleton forces statelessness
  • Assuming singleton prevents memory leaks

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes