Below I am giving a few ways to write the Singleton classes.
Please don't take these as final solution, rather analyse your requirements, usage & environment, then decide on the way of the implementation of the Singleton class, as you may find other way suitable to your requirements. So take the below ones just to get the ideas or satisfy those headless recruiters/interviewers who ask such questions with no proper understanding.
Please don't take these as final solution, rather analyse your requirements, usage & environment, then decide on the way of the implementation of the Singleton class, as you may find other way suitable to your requirements. So take the below ones just to get the ideas or satisfy those headless recruiters/interviewers who ask such questions with no proper understanding.