Can you explain the difference between lazy and eager initialization in Singleton?
- Eager Initialization: The Singleton instance is created at the time of class loading.
It's simple but can waste resources if the instance is never used.
- Lazy Initialization: The instance is created only when it is first accessed. It saves
resources but requires careful implementation for thread safety.
Factory pattern Q&A