ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Microsoft Related  >>  ASP.NET
 
 


 

 
 Visual Basic interview questions  Visual Basic Interview Questions
 C Sharp interview questions  C Sharp Interview Questions
 ASP.NET interview questions  ASP.NET Interview Questions
 VB.NET interview questions  VB.NET Interview Questions
 COM+ interview questions  COM+ Interview Questions
 ADO.NET interview questions  ADO.NET Interview Questions
 IIS interview questions  IIS Interview Questions
 MTS interview questions  MTS Interview Questions
 Crystal Reports interview questions  Crystal Reports Interview Questions
 BizTalk interview questions  BizTalk Interview Questions
 Dot Net interview questions  Dot Net Interview Questions
 Exchange Server interview questions  Exchange Server Interview Questions
 SharePoint interview questions  SharePoint Interview Questions
 Microsoft Related AllOther interview questions  Microsoft Related AllOther Interview Questions
Question
What is the Difference B/W Finalize() and Dispose() in .Net?
 Question Submitted By :: Muralisivam
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is the Difference B/W Finalize() and Dispose() in .Net?
Answer
# 1
.NET provides "finalize" method in which clean up our  
resources.but this is always not good so the best is to 
implement interface and implement the "Dispose" method 
where you can put your clean up routines
 
Is This Answer Correct ?    4 Yes 2 No
Prasanna
 
  Re: What is the Difference B/W Finalize() and Dispose() in .Net?
Answer
# 2
Both are ways to destroy the object. By object i mean when
you have some unmanaged resources used in your class, you
have to make sure that you write the logic to destroy them
in the finalize() method. But this is the implicit way of
destroying the unmanaged resources, as finalize is called by
garbage collector when it find thats there is no reference
to this object from the stack.
There is an explicit way to destroy the unmanaged resources.
That is by implementing IDisposable interface. By
implementing this interface, ie you have to write the code
to destroy the resource in Dispose() method, you can call
the object to destroy itself when ever required in your code.
 
Is This Answer Correct ?    12 Yes 0 No
Sreeram Pavan
 
 
 
  Re: What is the Difference B/W Finalize() and Dispose() in .Net?
Answer
# 3
The GC call the Finalize() function automatically to destroy
the object called implicit destroy. when you want to destroy
a  objects that you think no longer need and free it from
memory, then we will use the dispose function. For better
performance we will use the dispose function explicitly.
 
Is This Answer Correct ?    4 Yes 1 No
Vivek Jagga
 
  Re: What is the Difference B/W Finalize() and Dispose() in .Net?
Answer
# 4
A Dispose() method is explicit, meaning you code Dispose() 
up and explicitly call it in your application or system 
code. A Finalize() method is implicit, meaning you code 
Finalize() up but never actually call it — Finalize() is 
called behind the scenes by the .NET GC mechanism.

The GC call the Finalize() function automatically to destroy
the object called implicit destroy. when you want to destroy
a objects that you think no longer need and free it from
memory, then we will use the dispose function. For better
performance we will use the dispose function explicitly.
 
Is This Answer Correct ?    1 Yes 0 No
Sushma
 
  Re: What is the Difference B/W Finalize() and Dispose() in .Net?
Answer
# 5
when we write the destructor in c#,the runtime replaces the 
destructor with the finalize method in IL code,so we dont 
know at what time the destructor is called by the garbage 
collector.so the finalizer is non deterministic.if we want 
to do the garbage collection for unmanages resources,we 
have to implement our own destructor or finlizer 
method.but,the runtime will take two round trips to remove 
those objects from the heap.if runtime calls the own 
destructor,it will take onely one round trip.

to  remove the unmanaged resources without the performance 
issues,we have to inherit the System.Idisposable interface 
and implement the Dispose() method.here one problem is 
there,we have to write a code in a way that,the dsipose 
method must and should execute.
for that reason we have to keep the dispose methos for the 
objcets in the finally block.

problem with the dispose is that,some times because of 
some  problmes dispose() methos may not execute.
so the good practice is to use both to achieve the desied 
performance.
 
Is This Answer Correct ?    4 Yes 0 No
Karna
 
  Re: What is the Difference B/W Finalize() and Dispose() in .Net?
Answer
# 6
Dispose() Method is used to release Unmanage Resources. 
When Unmanage Resources are no longer in use and Referenced
and is called Manually.


and

Finalize() Method is similar to Dispose Method But it is 
called by the Garbage Collector.
 
Is This Answer Correct ?    2 Yes 0 No
Nitin Kumar
 
  Re: What is the Difference B/W Finalize() and Dispose() in .Net?
Answer
# 7
Finalize and dispose are used to clean the objects from 
memory. But Finalize will be called based on the GC. If you 
finalize any object that will be moved to Finalize queaue. 
When the time of the round trip of the GC. It will remove 
the objects from Finlize queaue.So,it will not destroy the 
object immediately. Unless dispose method will remove the 
object immediatley without considering the GC.
 
Is This Answer Correct ?    3 Yes 0 No
Rahupathi
 

 
 
 
Other ASP.NET Interview Questions
 
  Question Asked @ Answers
 
difference between <connectionstring> <Appsetting>  6
What is view state and how this can be done and was this there in asp ? Accenture1
What is shared and private assembly? Accenture1
Is data can be edited in the Repeater control?  2
Different type of validation controls in asp.net ? Keane-India-Ltd1
Whats an assembly IBM1
How Can we use multiple forms in single asp.net application? Polaris2
What is the result when the Web Form containing the following line is complied and executed? <asp:Button id=?thebutton? onClick=?theEvent? /> a) The button control is created; theEvent is the click event handler. b) Compiler error; the control must be set to runat=?server?. c) Compiler error; onClick is not a valid attribute. d) Runtime Exception; the control must be set to runat=?server?. Syntax-Softtech2
What are the types of assemblies and where can u store them and how a private assembly is used only by a single application, and is stored in that application's install directory (or a subdirectory therein)? Accenture3
How to merge 2 tables fields in DataTable in asp.net Wipro5
.net allows which inheritence AG-Technologies5
After building the custom control, you test it by adding an ASP.Net web application to the solution. You add a correct <%@ Register %> directive and a proper declaration of the control in the <asp:Form> tag to the Web Form, but when you execute the application you get an error. What is the most likely reason for the problem? a) The custom control must be compiled first. b) The web application must have a reference to the control c) The custom control must be registered with windows first. d) The assembly from the custom control is not in the application?s bin directory. Syntax-Softtech1
What is the function of the CustomValidator? a) It allows for custom C# client-side code to validate entries in a control. b) It allows for a custom mixture of validator controls to use one central control for the display of messages. c) It uses scripted client-side code to validate the entry in a control. d) It uses server-side code to validate the entry in a control. Syntax-Softtech2
How to send auto matic emails based on scheduled tasks to several of my clients  6
Where does the Web page belong in the .NET Framework class hierarchy? Visual-Soft1
Difference between DataView and DataTable  3
is it possible to access website from a remote place, without deploying it on web server?  1
What are Themes? What is their use ?  1
Tell About Global.asax ? Keane-India-Ltd3
I am using SQLServer 2005. I have one table called Drivers. Every day thousands of records will be added in this table. I have to show all these records in my GridView with out applying ajax timer beacause we don't know the time limit when the new record come to the table. Sometimes it will add for 10 seconds some times 20 seconds. There by Please try without using timer or any other soultion apply for the table in sqlserver. But, i want to see all records immediately when new record comes in table. How? Thanks in advance... Ramesh  5
 
For more ASP.NET Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com