LESSON 4 Flashcards

1
Q
  • One of the core concepts in object-oriented programming is inheritance.
    ●It is a mechanism that allows you to create a hierarchy of classesthat share a set of properties and methods by deriving a class from another class.
    ●_____ is the capability of one class to derive or inherit the properties from another class.
A

Inheritance

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

the class whose features are inherited by other classes

A

Super Class (Parent/Base Class)

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

The class that inherits the features of other classes. ___ __ can also have their own features in addition to the inherited ones.

A

Sub class (Child Class)

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

The concept where we can derive a new class from existing classes

A

Reusability

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

allows you to inherit the properties of a class, i.e., base class to another, i.e., derived class.

A

Inheritance

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

The benefits of Inheritance in Python are as follows

A

●It represents real-world relationships well.
●It provides the reusability of a code. We don’t have to write the same code again and again. Also, it allows us to add more features to a class without modifying it.
●It is transitive in nature, which means that if class Y inherits from another class X, then all the subclasses of Y would automatically inherit from class X.
●Inheritance offers a simple, understandable model structure.
●Less development and maintenance expenses result from an inheritance.

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

●To further understand this mechanism of OOP, we use the IS-A relationship, where we create a subclass by including the name of the parent class as a parameter

A

Inheritance

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

●A child class needs to identify which class is its parent class.
●This can be done by mentioning the parent class namein the definition of the child class.
●In order to properly use the attributes of the parent class, you must either:
●Invoke the constructor of the parent class
●Do not create a constructor for the subclass and use Getters and Setters instead.
●Invoke the constructor of the parent class

A

Subclassing

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

to access the parent’s class methods and functions.

A

super() function

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

If you forget to invoke the __init__() of the parent class then its instance variables would not be available to the child class (True or False)

A

True

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

Types of Inheritance

A

●Single Inheritance
●Multiple Inheritance
●Multilevel Inheritance
●Hierarchical Inheritance
●Hybrid Inheritance

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

●In __ ___, features of the base class and the derived class are further inherited into the new derived class.
●This is similar to a relationship representing a child and a grandfather.

A

multilevel inheritance

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

●When a class is derived from more than one base class, this type of inheritance is called
●In __ ___, all the features of the base classes are inherited into the derived class.

A

multiple inheritance

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

enables a derived class to inherit properties from a single parent class, thus enabling code reusability and the addition of new features to existing code.

A

Single inheritance

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

When more than one derived class are created from a single base, this type of inheritance is called ___ ___.
●In this program, we have a parent (base) class and two or more child (derived) classes.

A

hierarchical inheritance

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

●Inheritance consisting of multiple types of inheritance is called

A

Hybrid Inheritance

13
Q

●The word ____ means having many forms.
●In programming, ____ means the same function name (but different signatures) being used for different types.
●The key difference is the data types and number of arguments used in function.

A

polymorphism

14
Q

Python can use two different classes in the same way (true or false)

A

true

15
Q

it is not possible to modify a method in a child class that it has inherited from the parent class. (true or false)

A

(false) (“it is” not “it is not”)

16
Q

lets us define methods in the child class that have the same name as the methods in the parent class. In inheritance, the child class inherits the methods from the parent class.

A

Polymorphism