test object is global for Class1. so it will be in scope till the program end and it will holding its place in stack whereas it is not pointing anything in Heap. so it will be available for garbage collection once the program ends. As Garbage Collection only collect unreferenced memory.