Object Inheritance
One of the ways in which objects make programming faster is the ability to use one object to create a second object with expanded variables and functions. This is referred to as object inheritance.
Going back to the Human example, if the Human class has the attributes gender, height, weight, and birth date and it has the methods eating and sleeping, you could create another class called Adult that is an extension of Human. Along with the aforementioned variables and functions, an Adult object might also have the attribute of married and the method of working. As a rule, the child of a parent class inherits all the properties of the parent and then adds some new ones.
To make a child class from a parent, you use the extends ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access