Multiple choice technology programming languages

How you can force the garbage collection?

  1. Using delete operator

  2. Using destructor

  3. Garbage collection is an automatic process & cant be forced.

  4. None of the above

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

Garbage collection in languages like Java is an automatic process managed by the runtime environment. While you can suggest garbage collection using methods like System.gc(), you cannot force or guarantee when it will actually occur. The JVM decides based on memory needs and heuristics.