More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
Ans. We can follow the same design which we follow in singleton Classes. We can have a static counter that will keep the count of number of objects already created, We can keep the constructor private and being called through the static method. We can keep incrementing the counter before calling the constructor and put a check to call only if it's lesser than n.
Help us improve. Please let us know the company, where you were asked this question :