Amazon Interview Question

Simple programming questions (count character frequency, find pair that sums up to a certain value). Describe how Garbage Collector works in Java.