Topic: Programming in Java
What is the theoretical distinction between final, finally, and finalize() in Java?
- A. final is a modifier, finally is an exception completion block; finalize() is a deprecated cleanup method on Object.
- B. final controls thread visibility; finally manages memory deallocation; finalize() handles lock release.
- C. final restricts memory allocations; finally guarantees garbage collection; finalize() releases OS file descriptors.
- D. They are interchangeable syntactic mechanisms used across different editions of the JDK.
Answer: A. final is a modifier, finally is an exception completion block; finalize() is a deprecated cleanup method on Object.
Explanation: `final` is a keyword used as an access modifier to restrict class inheritance, method overriding, or variable reassignment. `finally` is a block used in `try-catch` structures to execute important code (like closing streams) regardless of whether an exception is thrown. `finalize()` is a method in the `Object` class that was historically called by the garbage collector before object destruction, but it has been deprecated in modern Java versions due to performance and reliability issues.