🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: JVM Memory and Garbage Collection: all 10 questions

Quiz: JVM Memory and Garbage Collection · Question 7 of 10

What does calling System.gc() do?

What does calling System.gc() do?

  1. A.It requests a garbage collection, which the JVM may perform or ignore
  2. B.It always frees all unreachable objects immediately
  3. C.It deletes all objects, reachable or not
  4. D.It increases the maximum heap size
Answer & explanation

Correct answer: It requests a garbage collection, which the JVM may perform or ignore

System.gc() is only a hint. The JVM decides when collection actually runs.

Can you get the rest right without peeking?

Take the timed Quiz: JVM Memory and Garbage Collection quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →