Java Design Pattern
Introduction to Java 10
Introduction to Java 11
Introduction to Java 12

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.
class A
	final int x=100;
	void get()
		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.

About the Author

Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc