OOP 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.
2
Q
what is an object
A
An instance of a class. It’s like a variable that contains data and can perform actions
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()