Multiple choice technology programming languages

Which method is used to call Garbage Collection explicitly?

  1. Out.gc()

  2. System.gc()

  3. Print.gc()

  4. None of the above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

System.gc() is used to suggest garbage collection to the JVM, though it's only a recommendation - the JVM decides when to actually run the garbage collector based on memory pressure and other factors.