HCLTech interview question

1) define garbage collector? 2) Write a code to reverse a string?