Topic 2 - Inheritance & Polymorphism Flashcards

1
Q

Inheritance

A

A relationship where a new class (subclass) can receive or inherit properties and methods from an existing class (superclass)

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

Superclass

A

The parent class that is being inherited from

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

Subclass

A

The child class that inherits from the superclass

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

Reusability in Inheritance

A

Subclasses can reuse methods defined in the superclass

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

Extensibility in Inheritance

A

Subclasses can extend the logic of methods inherited from the superclass

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

Inheritance Hierarchy

A

Classes are organized from general to specific, with more specific classes inheriting from more general ones

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

Implementing Inheritance

A

To create a subclass, declare it with the syntax: class Subclass(Superclass)

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

Subclass __init__ method

A

Must call the superclass __init__ method to initialize inherited attributes

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

Accessing Superclass methods

A

Can be done using Superclass.method(self) or super().method()

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

Method Overriding

A

Subclasses can override (redefine) methods inherited from the superclass

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

Polymorphism

A

Ability of subclasses to have methods with the same names as methods in their superclasses

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

Polymorphic Method Call

A

Program can call the correct method based on the object type

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

isinstance() function

A

Used to check if an object is an instance of a specific class

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