Oracle interview question

How is garbage collection achieved in Java.