Question: How do you force an object to be garbage collected?

  1. Set object to null and call Runtime.gc()
  2. Set object to null and call System.gc()
  3. Set object to null and call Runtime.getRuntime().runFinalization()
  4. There is no way to force an object to be garbage collected

Answer: The correct answer of the above question is Option B:Set object to null and call System.gc()