Singleton in Java
Date: Jul 2012
Level: Intermediate


INTERVIEW QUESTIONS

Company: IBM
Question Title: Singleton in Java
Language: Java
QUESTION DETAILS:

When would a Singleton not work as a Singleton?


Following are some of the scenarios where the Singleton might not behave as expected:

1. Multiple Singletons in Two or More Virtual Machines
2. Multiple Singletons Simultaneously Loaded by Different Class Loaders
3. Singleton Classes Destroyed by Garbage Collection, then Reloaded
4. Purposely Reloaded Singleton Classes
5. Copies of a Singleton Object that has undergone Serialization and Deserialization. For example, if you serialize a singleton and then deserialize it twice, you will have two instances of your singleton.
All Questions