Explain difference between final, finally and finalize?

Answer Posted / ranganathkini

When a class is marked final, it cannot be subclassed. When
a method is marked final, it cannot be overridden by the
subclass. And when a field is marked final, its value once
set, cannot be reset.

finally is the last clause in a try...catch block. It is a
block of statements that is executed irrespective if or if
not an exception was caught in the preceding try block.

finalize is a reserved method in Java, which can be
overridden by classes containing code to release any
expensive resources being held to by the object. Expensive
resources include, native peer objects, file/device/database
connections.

Is This Answer Correct ?    64 Yes 13 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between static variable and global variable?

554


What are 5 boolean operators?

630


If two threads have same priority which thread will be executed first ?

852


how we can make a write-only class in java?

565


Can we override protected method in java?

591






Explain about java sdk?

583


Justify your answer that you can't define a method inside another method in java, if you can then how?

608


What is the protected method modifier?

570


What is a percentage sign called?

625


Explain an intermediate language?

517


How do you print array in java?

565


Is void a return type?

557


What is difference between classpath and path variables in java?

567


Tell me how many ways are there to initialise an integer with a constant.

650


What is meant by javabeans?

620