Question 81

What is garbage collection in the context of Java?

  1. AThe Java Virtual Machine (JVM) checks the output of any Java program and deletes anything that does not make sense at all.
  2. BThe Operating System periodically deletes all of the Java files available on the system.
  3. CAny Java package imported in a program and not being used, is automatically deleted.
  4. DWhen all references to an object are gone, then the memory used by the object is automatically reclaimed.
Show answerHide answer

Correct answer: (D) When all references to an object are gone, then the memory used by the object is automatically reclaimed.

Explanation

Java's garbage collector automatically reclaims the memory of objects that are no longer referenced by any part of the program.

From DSSSB TGT Computer Science Practice Set 1

This is question 81 of DSSSB TGT Computer Science Practice Set 1. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.