Prev Next

Java / final keyword

What is the use of the final keyword in Java?

The final keyword can be used with a class, method, and variables.

With class, it prevents inheritance by not allowing to create subclasses.

With methods, it prevents overriding, you cannot override a final method in Java.

With variable, it is treated as constant because you cannot change their value once assigned.

More Related questions...

Show more question and Answers...


Comments & Discussions