Goldman Sachs Interview Question

1 Do you know how to implement garbage cleaning in Java?

Interview Answer

Anonymous

Jan 8, 2011

You cannot implement garbage collecting in Java. If you want garbage collection to occur, you have to use System.gc(); System.gc() is not a force call to the JVM, it merely is a suggestion to the JVM to do garbage collection. It is up to the JVM when garbage collection will occur. A simplified view of how garbage collection is implemented in the JVM: http://chaoticjava.com/posts/how-does-garbage-collection-work/