Google interview question

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

Interview Answers

Anonymous

31 Aug 2010

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

Anonymous

4 Jun 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.