Java Final Class

Java Final Class


Final Class In Java
 
Final keyword can be used with classes, methods, variables etc, but here we will see what is final class.
Before going to the final class first we must know why we need a final class  - 
Now we need a final class for one sole purpose only and that is - By making a class final it cannot be inherited by any other class.
In other words, no other class can extend the features of a final class.
Hence final class cannot be a subclass ever.
If we try to do so it will through a compile-time error.
 
Now we will see examples - 
 
Example - 
 
 
Output -