🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: JVM Memory and Garbage Collection: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. Where does the object created by Student s = new Student(); inside a method live?
  2. Q2. Which error is thrown when recursion never reaches a base case?
  3. Q3. What does this print? (code)
  4. Q4. When does an object become eligible for garbage collection?
  5. Q5. Two objects reference only each other, and no variable points to either. What happens?
  6. Q6. In this code, how many Box objects are eligible for GC at the end of main's body? (code)
  7. Q7. What does calling System.gc() do?
  8. Q8. Why does generational GC collect the young generation more often?
  9. Q9. Which code is most likely to cause a memory leak in a long-running server?
  10. Q10. Which JVM option sets the maximum heap size?