answered
The java virtual machine uses two kinds of memory , the stack(for method variable ) and heap (for objects)  each time an object is created its done in heap ..which the garbage collector free. ..upon each function calls function variables are held in stack which is destroyed when function returns..if you dig deeper then there is … Read more