What is the meaning of a final method and a final class?

Asked: May 17, 2023

The final keyword in a declaration of the method indicates that the method cannot be overridden by subclasses. A class that is declared as final cannot be subclassed.

This is especially useful when we are creating an immutable class like the String class. Only classes and methods may be declared final, properties cannot be declared as final.

Asked by brijesh

Answers (0)

No answers yet. Be the first to answer!