04.02 · Lesson
Inheritance & Encapsulation
Inheritance
Inheritance is a process in which one object acquires all the properties and behaviors of its parent object automatically. It enables reuse, extension, or modification of attributes and behaviors.
- Base Class: The class whose members are inherited.
- Derived Class: The class which inherits members of another class.
- Types: Single (one class inherits another), Multiple (deriving from two or more classes), Hierarchical (deriving more than one class from a base class), Multilevel (deriving from another derived class), Hybrid (combination of others).
- Visibility Modes: private, protected, public.
Encapsulation
Encapsulation is the process of combining data and functions into a single unit called class. Data is not accessed directly; it is accessed through functions inside the class.
- Data Hiding: Attributes are kept private and public getter/setter methods are provided. This restricts access and reduces negative effects due to dependencies.
Item 24 of 28 · updated 2026-10-12