Garbage Collections Questions and Answers

Take Exam

Garbage Collection in Java is a critical concept for memory management and performance optimization. This topic includes Java programming questions and answers related to JVM memory models, automatic garbage collection, and reference handling. Practicing garbage collection questions with answers helps learners prepare for TCS, Accenture, Infosys, and other software company interviews. A solid understanding of garbage collection enables developers to write efficient Java programs, reducing memory leaks and improving application stability.

Garbage Collections

Showing 10 of 32 questions

21. Which generation in heap memory contains newly created objects?

  • Old Generation
  • Young Generation
  • Permanent Generation
  • Meta Space
Show Answer Report

22. What happens if an object survives multiple garbage collection cycles in young generation?

  • It gets deleted immediately
  • It moves to old generation
  • It becomes permanent
  • It gets copied to permgen
Show Answer Report

23. Which garbage collector is designed for applications requiring short pause times?

  • Serial GC
  • Parallel GC
  • CMS GC
  • G1 GC
Show Answer Report

24. What is the permgen space in Java?

  • Permanent object storage
  • Temporary memory area
  • Class metadata storage area
  • Thread stack area
Show Answer Report

25. Which reference type always remains in memory until JVM needs memory?

  • Strong reference
  • Soft reference
  • Weak reference
  • Phantom reference
Show Answer Report

26. What is a memory leak in context of garbage collection?

  • Too frequent garbage collection
  • Objects being collected too early
  • Unintended retention of objects in memory
  • Automatic memory management
Show Answer Report

27. Which algorithm uses mark and sweep approach?

  • Copying collector
  • Mark and sweep
  • Generational collector
  • Incremental collector
Show Answer Report

28. What is the main advantage of garbage collection?

  • Faster execution
  • Automatic memory management
  • Smaller memory footprint
  • Better network performance
Show Answer Report

29. Which exception can occur if JVM runs out of memory?

  • NullPointerException
  • OutOfMemoryError
  • MemoryFullException
  • StackOverflowError
Show Answer Report

30. What is the young generation in Java heap divided into?

  • Old and Permanent
  • Eden and Survivor
  • Young and Old
  • Meta and Class
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test