Computer Science 1026A/B Lecture Notes - Lecture 10: Init, Object-Oriented Programming, Instance Variable

67 views8 pages
terubarenuka and 39895 others unlocked
COMPSCI 1026A/B Full Course Notes
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.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents