OOP Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

what is a class

A

A blueprint for creating objects. It defines a set of attributes (data) and methods (functions) that the objects created from the class will have.

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

what is an object

A

An instance of a class. It’s like a variable that contains data and can perform actions

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

examples of classes and objects

A

Class: Car

Attributes: color, model, year
Methods: drive(), brake()
Object: my_car (an instance of Car)

Attributes: color = ‘red’, model = ‘Toyota’, year = 2022
Methods: my_car.drive(), my_car.brake()

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