what are the differences between final,finally,finalize
methods?

Answer Posted / sunil

final variable is a constant.
final method cann't be overrid.
final class cann't be subclassed.

finally is a block usually used to release all the
resources utilized inside the try block such as to free
resources like stream objects, to close sockets .The code
in finally block is guaranteed of execution
irrespective of occurrence of exception catched/uncatched.

finalize() is never run more than once on any object.
finalize method is called by the garbage collector on an
object when the garbage collector determines that there are
no more references to the object.

Is This Answer Correct ?    30 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the drawbacks of singleton class?

529


What is an example of a boolean?

567


What is java dot?

491


what is use of functional interface in java 8?

556


Can we override a variable in java?

543






Explain wrapper classes in java?

528


In a container there are 5 components. I want to display all the component names, how will you do that?

1557


What is the use of predicate in java 8?

488


What is a void method?

513


What are the steps involved to write rmi based programs?

561


Is there a case when finally will not execute?

563


What are format specifiers in java?

593


Can you sort a string in java?

486


Why can't you declare a class as protected?

595


Where can i get Latest SUN Certification Dumps and what are the Sun Certification Codes that are available, Im new to JAVA, so please gimme info as i need to write J2EE - Core Java Certification

1367