Skip to content
Sharp

Object-oriented programming · interview question

Why does declaring a class as final in Java change runtime behavior?

Multiple choiceEasychapter-3-curatedpremiumoopdefensive-copying
Choose one answer
Answer and explanation

Correct answer

B. The class cannot be subclassed

Why

Declaring a class as final in Java prevents other classes from subclassing it. This can be useful when you want to make sure that the class's behavior cannot be altered through inheritance.

Test yourself on Object-oriented programming

A free test with instant, explained results. No account needed.

Start free test
All Object-oriented programming questions →