Control Structures
6. Exception Handling (try-catch)
6.3. BASIC OOP CONCEPT
1. Class
A class is a blueprint or template that defines what data (attributes) and actions (methods) an object can have. It’s like a plan for creating objects.
Key Points
· A class sets the structure but doesn’t hold actual data until an object is created.
· Example: A Person class might define that every person has a name and can say hello.
· In Java, classes are explicitly declared with types; in Python, they’re simpler and use dynamic typing.
Examples
Java:
class Person {
// Attributes and methods go here
}
Python:
class Person:
# Attributes and methods go here
pass