Bad singleton

Report a typo

Look at this unfortunate singleton implementation:

class BadSingleton {
    
    private static BadSingleton instance;
    
    public static BadSingleton getInstance1() {
        if (instance == null) {
            instance = new BadSingleton();
        }
        return instance;
    }
    
    public static BadSingleton getInstance2() {
        return new BadSingleton();
    }
}

What are the problems (excluding thread-safety)?

Select one or more options from the list
___

Create a free account to access the full topic