When you don't want any further modification to be done to your variable or a class or a method then
final keyword comes to your aid. It can be applied to variable, class and method. Applying the final keyword to the variable makes sure that your value is initialized only once and no one can initialize it. Applying final to the method makes you sure that your method is not overridden and applying final keyword to the class makes sure that your class can't be inherited by others.
You can see the error in the console while compiling the code because I initialized the value of a again to 3.
Here again you can see the error when I tried to inherit the class that was declared with