What is Final Keyword in Java?

Asked 7 years ago
Viewed 662 times

1

What is Final Keyword in Java? 


1 Answer


0

What is Final Keyword in Java?

Final keyword is used to make a constant variable, whose value is never changed. We can also say that when we use the final keyword with variables in Java, to specify it's values are not to be changed.

In Java, we declared a constant using the Keyword Final. Value can be assigned to the variable defined using Final keyword is only once and after assignment, the value of constant (a variable declared using final keyword) can't be changed.
In Java, the Final keyword is used to restrict the user. You can use the Final keyword with many contexts in Java. Which are as follows:
(i). variable
(ii). method
(iii). class
While we declared a Class by using Final Keyword, it can't inherit by a class or in other words it cannot be subclassed.

Hope it's informative...

answered 7 years ago by Hemant Patel

Your Answer