I have a singleton parent class extended by a child class which is not singleton. If i instantiate my child class more than once, will there be more than one object of parent class. Please clarify.
I mean, basically, i want to know if a child class is instantiated, will a new instance of the parent class will also be created. Please explain.
When you instantiate a class you don’t instantiate any of its parents. So technically where will be no instances of the singleton class.
However, if your ‘singleton’ class can be inherited (i.e. it’s not final), then it is not really a singleton.
For example all the members of it will be also in the child, so there will potentially be more than one instance of them – so it’s not really a singleton.