ByteDance interview question

How does java's garbage collection work?