What purpose do the keywords final, finally, and finalize fulfill?



What purpose do the keywords final, finally, and finalize fulfill?..

Answer / Babu Ram Yadav

These three keywords in Java serve different purposes:
1. final: Used to declare constants or variables that cannot be modified.
2. finally: A block of code that is guaranteed to be executed either when an exception occurs or after the execution of try-catch blocks, allowing for proper resource cleanup.
3. finalize(): A method in Object class that allows objects to perform cleanup before they are garbage collected. However, it should not be relied upon for critical tasks since the exact time when it is called is unpredictable.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

How to define a constant variable in Java?

1 Answers   TCS,


what is the diff b/w arraylist and vector?

6 Answers   Code Genesis, Genesis, Sprintine Labs,


Difference between error and exception

4 Answers   Nous, TCS,


How to sort array of 0 and 1 in java?

1 Answers  


What are the object and class classes used for?

1 Answers  


Why is a constant variable important?

1 Answers  


What is a java lambda expression?

1 Answers  


Can a static class implement an interface?

1 Answers  


What is generic type?

1 Answers  


What do bitwise operators do?

1 Answers  


What is primitive array?

1 Answers  


Does google use java?

1 Answers  


Categories