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.

Hiring? Job Hunting? Post a JOB or your RESUME on our JOB BOARD >>

Subscribe to our newsletter for more free interview questions.