Java Interview Question

Use this basic question and answer to prepare for your next Java interview.

What is the difference between: final, finally, finalize?

final is a keyword which can be used on a variable, class, or method.

  • final variables have constant values after the first assignment.
  • final methods cannot be overriden.
  • final classes cannot be inherited.

finally is a code block that is guaranteed to run after a throws block, even if the exception is not thrown.

finalize is a method invoked just before an object is collected by the GC to clean up the object.

Looking for developers?