What is an immutable method?
A method without any body.
A method which is declared as final.
A static method.
all are true.
All final methods are called as immutable methods.
Note: Immutable methods can't be overridden. That means it is not possible to give extra definition for immutable methods.
Purpose of immutable methods:
If a base class wants to give important functionality to its derived class, where base class don't want derived classes to override that functionality. In such cases final methods (immutable methods) can be used.
Back To Top