• Tutorials
  • Courses
  • Tracks

Memory Management & Garbage Collection Quiz

Last Updated :
Discuss
Comments

Question 1

Which component in C# primarily handles memory management?

  • Operating System

  • Common Language Runtime (CLR)

  • Programmer manually

  • Memory Manager Class

Question 2

Which type of memory stores value types, local variables, and method call details?

  • Heap

  • Stack

  • Global Memory

  • Register Memory

Question 3

Reference type objects in C# are stored in:

  • Stack

  • Heap

  • CPU Cache

  • Registers

Question 4

Which of the following is a characteristic of the heap?

  • Automatic allocation in LIFO order

  • Access is very fast

  • Managed by Garbage Collector

  • Stores method call details

Question 5

When does an object become eligible for garbage collection?

  • When it is created

  • When no variable holds a reference to it

  • Immediately after a method ends

  • Only when GC.Collect() is called

Question 6

Which generation contains newly allocated objects in C# Garbage Collection?

  • Generation 2

  • Generation 1

  • Generation 0

  • All generations

Question 7

Which GC method forces collection of all generations?

  • GC.GetTotalMemory()

  • GC.MaxGeneration

  • GC.Collect()

  • GC.WaitForPendingFinalizers()

Question 8

The IDisposable interface is used to:

  • Manage stack memory

  • Release unmanaged resources deterministically

  • Force garbage collection

  • Track object generations

Question 9

What is the advantage of using the using statement with IDisposable objects?

  • It makes objects live longer

  • It automatically calls Dispose() even on exceptions

  • It disables GC

  • It stores objects on the stack

Question 10

Which statement is correct regarding Destructor (~ClassName) vs IDisposable.Dispose()?

  • Destructor is deterministic, Dispose is non-deterministic

  • Destructor is called by programmer, Dispose by GC

  • Destructor is non-deterministic, Dispose is deterministic

  • Both run at exact same time

Tags:

There are 10 questions to complete.

Take a part in the ongoing discussion