i read in K&B that all objects are created/stored on heap and local variables(including object references) are created/stored in stack. But I want to know that where are the instance variables, which are primitives are stored... ?
The Sun Certification Results forum, where you posted this, is not for asking questions like yours, but for posting your result when you passed a Sun certification exam. I will move your post to a more appropriate forum.
gaurav pal wrote:can you tell me that how a heap does memory management i.e. how does it store new variables and deletes old variables... ?
Memory for Objects is allocated(on heap) when you create one using the "new" keyword. Freeing the memory is taken of by the garbage collector(which runs at its own discretion). Read up on garbage collection.
In Java, you dont have to worry about explicit memory allocation and de-allocation like you'd have to in C[malloc and free].
That said, you still have to take care that your code has no memory leaks and that it uses the memory efficiently.