How can a singleton class be broken, and how do you make sure only one object is created?

A Singleton class is designed to ensure that only one instance of a class exists throughout the application's lifecycle. However, improper implementation can allow multiple instances to be created through mechanisms such as reflection, serialization, or cloning. To maintain the singleton guarantee, additional safeguards must be implemented. Among all approaches, using an enum-based singleton is considered the most secure and reliable solution.

Key Points

Example

Consider a ConfigurationManager class intended to have only one instance. If someone uses reflection or deserializes a serialized object, additional instances may be created. Using an enum-based singleton eliminates these risks while keeping the implementation simple.

public enum ConfigurationManager {

    INSTANCE;

    public void loadConfiguration() {

        System.out.println(
                "Configuration Loaded");
    }
}

public class Main {

    public static void main(String[] args) {

        ConfigurationManager manager =
                ConfigurationManager.INSTANCE;

        manager.loadConfiguration();
    }
}

Interview Tip

A concise interview answer is: A Singleton can be broken through reflection, serialization, or cloning if not implemented carefully. To prevent this, use constructor guards, implement readResolve(), disable cloning, or preferably use an enum-based singleton, which provides the safest and simplest strategy for ensuring a single object instance.

Last updated: 11 November 2026

Previous question: Why do we use builder design pattern rather than constructor-based object creation?

Next question: What is deep and shallow cloning, and how is the Cloneable interface used?

More Core Java - Level IV (Advanced) interview questions

All Core Java - Level IV (Advanced) questions