health

Technology

business posts

Powered by Blogger.

Total Pageviews

Name

your name

Email *

Your Email

Message *

your message

Followers

Translate

Pages

Pages

how final modifier works in java

In Java, what does the ‘final’ modifier mean when applied to a method, class, and an instance variable?

 

  • When applied to a method definition the final modifier indicates that the method may not be overridden in a derived class.
  • When applied to a class, the final modifier indicates that the class can not be used as a base class to derive any class from it. It’s also good to point out in an interview that the final modifier, when applied to either a class or a method, turns off late binding, and thus prevents polymorphism.
  • And, when applied to an instance variable, the final modifier simply means that the instance variable can’t be changed. 

No comments: