final – some quick facts

  • A final class can’t be a base class
  • A final method can’t be overridden
  • A final variable is a constant.
  • Generally you should avoid declaring final methods, though you think that a subclass wouldn’t need to override a method
  • final methods execute a bit more efficiently than non-final methods, because the compiler knows at compile time that a call to a final method can’t be overridden.
  • private methods are automatically considered as final
  • Though it is not required, using a static keyword is common for all final variables.

image

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top