Final Members: A way for Preventing Overriding of Members in Subclasses
All methods and variables can be overridden by default in subclasses.
This can be prevented by declaring them as final using the keyword “final” as a modifier. For example:
final int marks = 100;
final void display();
This ensures that functionality defined in this method cannot be altered any. Similarly, the value of a final variable cannot be altered.
Final and Abstract Classes – Back to Basics :-)