R_K_T_ASHOKA,
I think youre getting confused between classes, objects and instances
A class is a blueprint object for an instance object. Everything is an object here, so we should stop referring to them as objects.
When an instance of a class is created it goes in memory somewhere. Then, we say that the type of the instance is (name of class)
In your case, you have an instance of Sample, referred to by a variable named obj. Sample, the class, does not own this instance and Sample (as a class) does not have instances. The heap (computer memory) might hold objects that are instances of the class type Sample, but not the other way round.
Like i said before, you either keep a count yourself, in the constructor (Factory pattern - each object must have a link to the factory that created it and when it is being disposed of it informs the factory thus) or you enumerate the heap and find out how many instaces of type X the heap holds. I dont know how or if this is possible, but it would be a reflective method and not recommended
Here's a better idea: You should tell us why you want to do this. Frequently people come here and they say "I have a problem and the solution i have devised is X, but i cant make it work. What is wrong with my solution?"
What they should be asking is "Here is my goal. How can i reach my goal?"
The difference is that we solve your actual problem, not the difficulty youre encountering with your particular solution to your problem (which may not be the best solution). SO.. tell us the actual problem?