2a. Understanding Inheritance Flashcards

1
Q

What does inheritance do?

A

Inheritance defines a way for a given class to inherit attributes and methods from one or more base classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why does inheritance make easy?

A

Inheritance makes it easy to centralise common functionality and data in one place instead of having it spread out and duplicated across multiple classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What syntax does a class use to inherit another?

A

The name of the class to be inherited in parentheses as a postfix.

eg. class Child(Parent):

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How does a subclass access its parent’s attributes and methods?

A

By using a dot notation after calling the super function.

eg. super().attribute

How well did you know this?
1
Not at all
2
3
4
5
Perfectly