OOP Flashcards

(10 cards)

1
Q

What is OOP?

A

A way to model real-world entities using classes (blueprints) and objects (instances).

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

Class vs Object

A

Class = blueprint

Object = actual instance created from class

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

What is self?

A

The current instance of the class (the object itself).

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

What is inheritance?

A

A child class reuses and extends properties of a parent class.

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

What are dunder methods?

A

Special methods (__xyz__) that define how objects behave with built-in operations.

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

What is __str__ used for?

A

Returns a user-friendly string (used in print()).

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

What is __repr__ used for?

A

Returns a developer-friendly, unambiguous representation.

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

What does __eq__ do?

A

Defines how objects are compared using ==.

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

What does __len__ do?

A

Defines what len(obj) returns.

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

What is the main goal of OOP?

A

To organize code into reusable, structured, real-world-like objects.

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