Skip to content
Sharp

Object-oriented programming · interview question

Which of the following best describes a scenario where inheritance is appropriately used in Java?

Multiple choiceMediumchapter-5-curatedpremiumoopcomposition-vs-inheritance
Choose one answer
Answer and explanation

Correct answer

B. When subclasses naturally extend the behavior of the superclass.

Why

Inheritance is appropriate when subclasses naturally extend the behavior of the superclass, such as when subclasses represent a specific type of the superclass. This relationship should be a 'is-a' relationship, ensuring that subclasses maintain the integrity of the superclass.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →