final Modifier:-
the final is a modifier applicable for method, classes & variables.
1.final method:-
Whatever method parent class has by default available to the child class through inheritance.
If the child class is not satisfied with the parent method implementation than the child is allowed to redefine that method based on its requirement, this process is called "Overriding".
But,
If the parent class method declared as final then we can't override that method in child class. Because it's implementation is final.
example:-
class Parent
{
public void property()
{
System.out.println("parent property");
}
public final void marriage()
{
System.out.println("parent choice girl");
}
class Child extends Parent
{
public void marriage()
{
System.out.println("Child choice girl");
}
}
Compile Time Error: marriage () in Child cannot override marriage () in Parent; Overridden method is final.
2. final class:-