Ask a question
          

Interview questions

What is Finalizer?

Next question>>                   Learn .NET
NET - What is Finalizer? Explain how to implement it. - June 08, 2009 at 08:00 AM by Shuchi Gauri

What is Finalizer? Explain how to implement it.

It is a method that is executed when an object is garbage collected. It is similar in function to a destructor. It keeps the memory managed by taking appropriate an action against an object that is released or is no longer in use. It is called up internally on garbage collection.

protected override void Finalize()
{
    try
    {
            //Cleanup all the resources
    }
    finally
    {
         base.Finalize();
    }
}


Next question>>

Also read

What is the difference between Finalize() and Dispose()?

Dispose() is called by as an indication for an object to release any unmanaged resources it has held................

What is Finalize method in .NET?

Object.Finalize method in .NET is typically used to clean and release unmanaged resources like OS files, window etc.................

What are the concepts of DISPOSE method?

Dispose method belongs to IDisposable interface. It is used to free unmanaged resources like files, network connection etc.................

.NET garbage collection

What is garbage collection?
Is it possible to force garbage collection to run?
Define Dispose().
Explain how garbage collection manages reclamation of unused memory in .NET.
Explain how garbage collection deals with circular references..................

Explain why we should close and dispose resources in a Finally block instead of Catch block.

Catch block gets called only when an exception occurs or is explicitly thrown......... 



Write your comment - Share Knowledge and Experience


 

 
Latest placement tests
Latest links
 
 
Home | Login | About us | Sitemap | Contact us