Object Oriented Programming Flashcards

1
Q

What is an object in OOP?

A

an entity or thing in your program

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

how do you create objects in Python?

A

Using classes. Classes define a type (not default types like str, int). Process of creating an object from that class is called instantiation.

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

True or False - Objects of the same class are independent of each other.

A

True. The class just tells python how to create the objects.

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

Write a class named Dog that has no input parameters and all it does is pass.

A
class Dog:
    pass
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are instance attributes?

A

Attributes that are independent to each object

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

What value do you pass in for ‘self’ when creating an object?

A

Nothing. Self is used to refer to the current object being created during instantiation.

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

What does self mean?

A

Take the value we are passing in and assign it to the attribute for the new instance.

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

What are class attributes?

A

Attributes that are the same for each instance of the class.

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

What is an instance method?

A

An instance method is a function that belongs to a class. Just like functions, these methods can accept parameters, and they can access the attributes of the object they belong to.

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

What is inheritance?

A

Inheritance is the OOP concept that allows one class to subclass another.

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

What is overwriting in Python when referring to class attributes?

A

Overwriting can allow for a class which inherits attributes from a parent, to overwrite one of the attributes.

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

Can you overwrite / add methods to children classes?

A

Yes.

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