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 an image buffer?

531


Where is singleton pattern used?

520


What is the function of http?

527


What happens if constructor is private?

559


What is difference between an object and a class?

605






Explain where variables are created in memory?

578


Why java is made?

561


what is nested class in java?

597


Is 0 an irrational number?

598


What is an immutable object?

578


What are the high-level thread states in java programming?

581


What is return type in java?

628


What is procedure overloading?

1796


Why is whitespace important?

549


What is the difference between yielding and sleeping in java programming?

584