Interview Question

What are classes and objects?

Classes define behavior; instances hold individual state.

💡 Concept ✅ Quick Revision 🐍 Python

Answer

A class is a callable object used to create instances; an object is an instance or any Python value. • A class body creates a class namespace. • Instances usually store per-object attributes. • Attribute lookup can continue through the class and base classes.

💡 Simple Example

class User: role = 'member' user = User() user.name = 'Maya' print(user.name, user.role)

Output

Maya member

⚡ Quick Revision

Classes define behavior; instances hold individual state.