Thursday, September 14, 2006

What is the difference between final, finally and finalize() in Java?

final - keyword is constant declaration.

finally - handles exception. The finally block is optional and provides a mechanism to clean up regardless of what happens within the try block (except System.exit(0) call). Use the finally block to close files or to release other system resources like database connections, statements etc.

finalize() - method helps in garbage collection. A method that is invoked before an object is discarded by the garbage collector, allowing it to clean up its state. Should not be used to release non-memory resources like file handles, sockets, database connections etc because Java has only a finite number of these resources and you do not know when the garbage collection is going to kick in to release these non-memory resources through the finalize() method.


At 3:43 AM, Blogger Kumarappan said...

Your blog of java queries are very nice

thank you!!!

At 6:34 PM, Blogger Prakash said...

Please send me usage of Mouse Event in applet.

At 11:38 PM, Blogger Govindarajan said...

Through mouse event,we can declare and define function for mouse movement.It is very interesting.we can develop games on that..


Post a Comment

<< Home