Question

Which of the following best describes the primary purpose of inheritance in OOP?

A To allow a class to hide its internal data from external classes
B To enable a class to acquire properties and behaviours of another class, promoting code reuse
C To allow a single method to behave differently based on the object calling it
D To define a contract that a class must implement
E To allow multiple objects to share a single method implementation stored in memory
Practice Next

Hey! Ask a query