Java final keyword
- The keyword final is a modifier that can be used with variable, method, and class.
- When a variable is declared as final, then the value of that variable never changed for whole class. If we are trying to change, then it will give a compile time error.
final int x=100;
x=200; //compile time error
- When a method is declared as final, then that method never overridden. If we will try, then it will give compile time error.
- When a class is declared as final, then that class never inherited.
Final variable : value never changed
Final method : method never overridden
Final class : class never inherited
Can final method inherited?
Yes, it is possible we can inherit final method but cannot override it.
Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Data Science with Python Training | Projects
SILAN Technology, BBSR Call to: 0674-2361252