OOP
Object-oriented programming groups state and behavior into objects and classes.
The question library
Explore practical questions, clear explanations, and code examples across developer technologies.
Showing 2941–2952 of 3610 questions
Object-oriented programming groups state and behavior into objects and classes.
__init__ initializes an instance; self conventionally refers to that instance.
Inheritance lets a class extend a base class when the subtype relationship is meaningful.
Composition builds objects from collaborating objects and can reduce deep inheritance coupling.
A property exposes method logic through attribute access.
Duck typing focuses on supported behavior rather than explicit inheritance.
A virtual environment isolates project dependencies from other projects.
Declare dependency ranges or pins in project metadata and install them in the intended environment.
logging supports levels, handlers, formatting, and configurable output.
Unit tests verify small behaviors in isolation and should be deterministic.
Mocks replace dependencies to control responses and check interactions.
mypy and pyright analyze type annotations to find likely errors without running every code path.