Multiple choice technology programming languages

A method declared as final

  1. Can be overridden

  2. Cannot be overridden

  3. Can be inherited

  4. Cannot be inherited

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

A final method cannot be overridden in subclasses. This enforces that the implementation remains unchanged throughout the inheritance hierarchy. However, final methods can still be inherited and called by subclasses.

AI explanation

A method declared final in Java cannot be overridden by a subclass — that is precisely the purpose of the final modifier on a method: it locks in the implementation so subclasses can't change its behavior via overriding. It can still be inherited (subclasses can call/use it) and can be overloaded, just not overridden. So 'Cannot be overridden' is correct, while 'Can be overridden' and 'Cannot be inherited' directly contradict how final methods actually behave.