
Python OOP
Classes, inheritance, polymorphism, magic methods, dataclasses, property decorators
1What is a class in Python?
What is a class in Python?
Câu trả lời
A class is a blueprint for creating objects. It defines attributes (data) and methods (behaviors) that objects created from this class will have. In Python, a class is defined with the class keyword and allows encapsulating data and functionality together, promoting code reuse and organization.
2What is the role of the __init__ method in a Python class?
What is the role of the __init__ method in a Python class?
Câu trả lời
The __init__ method is the constructor of a Python class. It is automatically called when creating a new instance. Its main role is to initialize the instance attributes with the values passed as parameters. The first parameter is always self, which refers to the instance being created.
3What is the difference between a class attribute and an instance attribute?
What is the difference between a class attribute and an instance attribute?
Câu trả lời
A class attribute is defined at the class level and shared by all instances. Modifying this attribute affects all existing instances. An instance attribute is defined in __init__ with self and is unique to each instance. Each object has its own copy of the instance attribute.
What is the purpose of the self parameter in Python class methods?
How to implement simple inheritance in Python?
+17 câu hỏi phỏng vấn
Các chủ đề phỏng vấn Django khác
Python Basics
Django Fundamentals
Django Models - Basics
Django Views
Django Templates
Django Forms
Advanced QuerySets
Django Authentication
Django Middleware
Django Admin
Django REST Framework
Django Signals
File Upload
Django Caching
Django Sessions
Django Email
Django Testing
Django Security
Django Deployment
Advanced Django ORM
Django Performance
Django & Celery
Django Channels
Django & GraphQL
Django & Docker
Django in Microservices Ecosystem
Custom Django Commands
Django Internationalization
Django Design Patterns
Django Async & ASGI
Settings & Production Configuration
Observability & Monitoring
Nắm vững Django cho lần phỏng vấn tiếp theo
Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.
Bắt đầu miễn phí