srikanth prasad wrote:What are the different ways to find number of alive instances of a class?
That's a very open-ended question, and there's no one right answer. If that's what the interviewer asked, then there are two possibilities:
1. He's a lousy interviewer, or at least didn't put much thought into this particular question.
2. He wants to see about your thought process, give you the chance to explore options or ask for clarification, etc.
If it's #1, then he's probably looking for one specific (and arbitrary) answer. Even though many different answers might be technically correct for different interpretations of that question, he probably will only accept one particular one. Nobody here can know what answer he's expecting.
If it's #2, then there's still not one correct answer, but putting forth different possibilities, indicating their limitations, and asking for clarifications about the actual requirement, would be the way to go.