Bird
Raised Fist0

Which of the following problems CANNOT be effectively solved using the Singleton Pattern with thread safety and lazy initialization?

easy🔍 Pattern Recognition Q2 of Q15
OOP & Design Patterns - Singleton Pattern - Thread Safety, Double-Checked Locking & Lazy Init
Which of the following problems CANNOT be effectively solved using the Singleton Pattern with thread safety and lazy initialization?
AGuaranteeing a single logger instance accessible globally
BProviding a global configuration manager with lazy loading
CEnsuring a single database connection instance across threads
DLimiting the number of instances to a fixed maximum greater than one
Step-by-Step Solution
Solution:
  1. Step 1: Analyze each problem's suitability for Singleton

    Singleton enforces exactly one instance; limiting to multiple fixed instances is not Singleton.
  2. Step 2: Identify which problem cannot be solved by Singleton

    Limiting instances to a fixed number >1 requires Multiton or other patterns, not Singleton.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    Only option limiting multiple instances >1 is not solvable by Singleton [OK]
Quick Trick: Singleton allows only one instance, not multiple fixed instances [OK]
Common Mistakes:
MISTAKES
  • Assuming Singleton can limit multiple instances
Trap Explanation:
PITFALL
  • Candidates often think Singleton can limit instances to any fixed number, but it only allows one.
Interviewer Note:
CONTEXT
  • Tests anti-pattern recognition and understanding Singleton limitations
Master "Singleton Pattern - Thread Safety, Double-Checked Locking & Lazy Init" in OOP & Design Patterns

2 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More OOP & Design Patterns Quizzes