Google Interview Question

The key thing was understanding how the java garbage collector worked.

Interview Answers

Anonymous

Aug 31, 2010

It scans the stack, looking for pointers into the heap. Any object in the heap with no pointer is unused.

Anonymous

Jun 4, 2012

I don't understand why allegedly brilliant programmers keep asking this question. There is no single way garbage collection works because the JVMS doesn't even require garbage collection. It's JVM dependent.