Computer Science 1026A/B Lecture Notes - Lecture 10: Init, Object-Oriented Programming, Instance Variable
![COMPSCI 1026A/B Full Course Notes](https://new-docs-thumbs.oneclass.com/doc_thumbnails/list_view/2239487-class-notes-ca-western-cs-1026ab-lecture7.jpg)
26
COMPSCI 1026A/B Full Course Notes
Verified Note
26 documents
Document Summary
In this chapter, you will learn how the notion of inheritance expresses the relationship between specialized and general classes. In object oriented programming, inheritance is the relationship between: a superclass: a more generalized class and, a subclass: A more specialized class: richer state and more capabilities. The subclass inherits data (variables) from the superclass. The substitution principle car is a vehicle, means car is a subclass of the superclass vehicle, and car shares common traits with vehicle. The substitution principle says: if a progam asks for a superclass object , you can substitute it with a subclass object: for example; if a program asks for vehicle object you can replace with is-a car object. In python, every class that is declared without a specific superclass; is automatically extended to the superclass object . To create a subclass, include the name of the superclass inside parentheses of the header. All methods that it does not override.