Skip to content

Q 20 - final finally finalize #24

Discussion options

You must be logged in to vote

final

  • Keyword used to restrict modification
  • Can be applied to variables, methods, or classes
  • final variables can't be reassigned
  • final methods can't be overridden
  • final classes can't be subclassed

finally

  • Block of code in a try-catch-finally statement
  • Executes regardless of whether an exception is thrown
  • Typically used for resource cleanup (e.g., closing files, connections)

finalize

  • Method in the Object class (deprecated since Java 9)
  • Called by the garbage collector before an object is garbage collected
  • Used to release system resources (rarely used and not recommended)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by AmjustGettingStarted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants