10.6 Summary

We have introduced the notion of object inheritance and shown some examples.

10.6.1 Key Concepts

  • One of the most powerful tools in object-oriented programming (OOP) is that objects can be created from other objects and use the resources of the parent object. This is known as inheritance. In this relationship, the parent class or superclass defines the relationship with the child class or subclass.

  • Subclasses inherit both data and methods from their parent class.

  • A key point to keep in mind when working with inheritance is that polymorphism often takes place, which in some cases can lead to a need for method overriding.

10.6.2 Key Definitions

  • Inheritance: When the relationship between two classes is defined.

  • Superclass: The class that defines the object for the relationship.

  • Subclass: The class for which the relationship is defined.

  • Method overriding: When the method for a parent class is redefined for a child class.

  • Polymorphism: Allows different data types to be handled by a unified interface.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.178.211