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

Answer Posted / ravi

A "final" method or variable is one that can't be overridden
- you can define a method as final within a class to ensure
that any extensions to the class don't replace it.

If you add a "finally" block onto the end of a try / catch
exception handler, you're defining a block of code that will
be run if the try is entered, even if problems occur and
your method returns from within a catch rather than continuing.

A "finalize" method is your destructor method - code that's
run to clean up objects that are no longer required. For
example, objects which are memory cached would be flushed
back to the disc in your finalize.

Is This Answer Correct ?    8 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are constructors in java?

798


What are the differences between include directive and include action?

802


What is string in java? String is a data type?

802


Can you explain the private protected field modifier?

808


What is a Hash Table? What are the advantages of using a hash table?

875


Write a code to show a static variable?

869


Does treeset allow null in java?

738


What is return type in java?

860


Can interface be private in java?

782


Do I need java for windows 10?

801


What are the escape sequences in java?

788


What is an image buffer?

763


What is the new line character?

872


What are methods of a class?

792


Is java 9 released?

767