22 Oct 2023
Beginner
In Object-Oriented Programming (OOP), a class is a blueprint for creating objects. It defines the structure and behavior of objects that belong to that class.
Examples:
- Class:
Car- Attributes: Make, Model, Year
- Methods: Start, Stop, Accelerate
Class: Car
----------------------
Attributes:
- Make
- Model
- Year
Methods:
- Start()
- Stop()
- Accelerate()
- Class:
Person- Attributes: Name, Age, Gender
- Methods: Walk, Talk, Eat
Class: Person
----------------------
Attributes:
- Name
- Age
- Gender
Methods:
- Walk()
- Talk()
- Eat()