Stack and the heap both are stored in the computer’s RAM. In a multi-threaded application, each thread will have its own stack. But, all the different threads will share the heap. object can be stored on the stack if an object is created inside a function without using the “new” operator.
Once a function call runs to completion, any data on the stack created specifically for that function call will automatically be deleted. Any data on the heap will remain there until it’s manually deleted by the programmer.

