A method that is declared final is called a final method. We cannot override a final method. This means the child class can still call the final method of the parent class without any problem, but it cannot override it. This is because the main purpose of making a method final is to stop the modification of the method by the sub-class.
#Source_code
#OOP_Concepts_java
#Final_Method_in_java
#128
#Source_code
#OOP_Concepts_java
#Final_Method_in_java
#128
Java
A method that is declared final is called a final method. We cannot override a final method. This means the child class can still call the final method of the parent class without any problem, but it cannot override it. This is because the main purpose of…
Instead of modifying the method, we can use it as shown:
#Source_code
#OOP_Concepts_java
#Final_Method_in_java
#129
#Source_code
#OOP_Concepts_java
#Final_Method_in_java
#129