Bird
0
0

Which of these is NOT a typical trigger for Java's garbage collector to run?

easy📝 Conceptual Q2 of 15
Java - Memory Management Basics
Which of these is NOT a typical trigger for Java's garbage collector to run?
AWhen the program finishes executing a method
BWhen the JVM runs low on heap memory
CWhen the program explicitly calls System.gc()
DWhen memory allocation fails
Step-by-Step Solution
Solution:
  1. Step 1: Identify triggers for garbage collection

    Garbage collection usually runs when the JVM runs low on heap memory, memory allocation fails, or when System.gc() is called.
  2. Step 2: Analyze each option

    Options A, C, and D are typical triggers. When the program finishes executing a method (when the program finishes executing a method) does not trigger garbage collection automatically.
  3. Final Answer:

    When the program finishes executing a method -> Option A
  4. Quick Check:

    Garbage collection triggers exclude method completion [OK]
Quick Trick: Garbage collection triggers exclude normal method completion [OK]
Common Mistakes:
  • Assuming method end triggers garbage collection
  • Confusing explicit calls with automatic triggers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes