233k views
4 votes
Object-oriented programming allows you to derive new classes from existing classes. This is called ____________.

A. encapsulation
B. inheritance
C. abstraction
D. generalization

User Paligap
by
8.3k points

1 Answer

6 votes

Final answer:

In object-oriented programming, the process of deriving new classes from existing ones is known as inheritance, which is essential for promoting code reusability and establishing a hierarchical class structure.

Step-by-step explanation:

In object-oriented programming, when you derive new classes from existing classes, this is known as inheritance. Inheritance allows for the creation of a subclass that inherits attributes and behaviors (methods) from a parent or base class, while also having the ability to introduce its own unique properties and methods or override the existing ones. It's a fundamental concept that enables code reusability and the creation of a hierarchical structure of classes. For example, if you have a base class Vehicle, you could inherit characteristics and functions to create more specific classes like Car or Truck, which would have all vehicles' common features plus their own specific attributes.


User Prism
by
8.3k points