mod08 - Python Object-Oriented Programming Flashcards

1
Q

What is data encapsulation?

A

Binding data into a single object.

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

What is data hiding?

A

Access to an object’s data.

Object’s ability to hide its data attributes from code that is outside of the object.

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

What is inheritance?

A

Makes a new object based on an existing object.

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

What is polymorphism?

A

Object’s ability to take different forms.

Allows 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
5
Q

What is __init__()?

A

Constructor AKA the initializer. Does not return the new instance of a class.

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

What is __del__()?

A

Deconstructor

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

What is __new__()?

A

First step of instance creation. Unlike __init__(), this dunder method RETURNS the new instance of a class.

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

What is the difference between __str__() and __repr__()?

A

__str__() returns a human-readable string representation of an object.

__repr__() returns the official object representation in string format. This can be used to reconstruct the object.

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

What is __eq__()?

A

Compares two objects using ==

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

What is the purpose of an accessor method?

A

It is used to access hidden data in the object. If a setter method isn’t used alongside the accessor method, it is known as a read-only attribute.

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

What is the purpose of a mutator method?

A

It is used to modify the hidden value of an object.

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