Aruna Balasuriya wrote:What will happen when we mark a method as final
When you mark a method final you are saying that there would be no alternate implementations of the method. Usually, alternate implementations are provided by overriding the same method in sub-classes so this means you cannot override a final method.
Also, there could be other optimizations done at different levels once you provide that sort of commitment (for e.g. a compiler can inline your method code).
It means that same as marking private??
When you mark your method private you are limiting the visibility or accessibility of your method. The method will not be visible, inherited by your sub classes.
I think, you would agree that limiting accessibility and controlling alternate implementations are two different types of control.