Inheritance

The main concepts of object-oriented programming languages are: encapsulation, inheritance, and polymorphism. In an object-oriented language, objects are related to others by establishing hierarchies, and it is possible that some objects inherit the properties and methods of other objects, extending their behavior and/or specializing. 

Inheritance allows us to generate a new class from another, inheriting its attributes and methods, adapting or expanding them as necessary. To indicate that a class inherits from another class, we need to put the name of the class that is inherited between parentheses.

In OOPS terminology, it is said that "B inherits from A," "B is a class derived from A," "A is the base class of B," or "A is a superclass of B."

This facilitates the reuse of the code, since you can implement the basic behaviors and data in a base class and specialize them in the derived classes:

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

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