EPAM Systems interview question

How does garbage collection work in Java.