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