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 |
How to define a constant variable in Java?
what is the diff b/w arraylist and vector?
6 Answers Code Genesis, Genesis, Sprintine Labs,
Difference between error and exception
How to sort array of 0 and 1 in java?
What are the object and class classes used for?
Why is a constant variable important?
What is a java lambda expression?
Can a static class implement an interface?
What is generic type?
What do bitwise operators do?
What is primitive array?
Does google use java?