Explain final, finalize() and finally?

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 ?    4 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is core java important?

661


Can you sort a string in java?

576


How many decimal digits is 64 bit?

620


Give us a program to check for parenthesis matching using stack.

639


How can we make copy of a java object?

645






Explain about arraylist?

663


What is a arraylist in java?

655


How does enum work in java?

638


What is difference between hashset and hashmap in java?

560


What are the different data types in java?

610


What is the method in java?

721


What are parsers? Dom vs sax parser.

650


What is a class reference?

649


What is meant by memory leak?

622


What is string value?

726