What is garbage collection in the context of Java?
1
The operating system periodically deletes all of the Java files available on the system.
2
When all references to an object are gone, then the memory used by the object is automatically reclaimed.
3
Any java package imported in a program and not being used, is automatically deleted.
4
The java virtual machine (JVM) checks the output of any java program and deleted anything that does not make sense at all.