1. Subclass
  2. Superclass
  3. Reusability
  4. Need for Inheritance
  5. Can OOP exist without Inheritance
  6. Inheritance types (Single, Multiple, Hierarchical, Multilevel, Hybrid, Virtual Inheritance)
  7. Real-life examples of Inheritance
  8. Limitation of Inheritance
  9. Sealed Modifier
  10. Object Slicing

1. Subclass

A subclass is a class that inherits from another class, known as the parent or base class. It is a way to create a new class that extends or specializes the behavior of an existing class.

Key Characteristics of a Subclass:

  1. Inheritance: A subclass inherits properties and methods from its parent class. This means it can use, modify, or extend the functionality provided by the parent class.
  2. Extension: A subclass can add new properties and methods that are not present in the parent class. It can also override existing methods to provide specialized behavior.
  3. Specialization: A subclass can provide more specific implementations or additional functionality based on the general behavior defined by the parent class.

Example in Swift

Here’s a simple example illustrating a subclass in Swift: