Skip to content
Tech Interview Prep home
Technical interview guide

OOP & Data Classes

Classes, inheritance, and the @dataclass shortcut for the common case of a class that's mostly just data.

Read
50 min
Practice MCQs
25
Interview QA
25
Edition
v2
Editorial status
Reviewed

Scope: Python 3.14 object model, dataclasses, typing.Protocol, and abstract base classes.

Interview QA

Treat each question like a live interview question: answer out loud first (structure, assumptions, tradeoffs), then open the model answer to spot gaps and rehearse a tighter follow-up.

Curated: · Written: · Reviewed:

QA-1

Contrast instance and class attributes for mutable state.

QA-2

Design a polymorphic alternate constructor with `classmethod`.

QA-3

Explain C3 method resolution in a diamond hierarchy.

QA-4

Explain bound-method creation and the role of the descriptor protocol.

QA-5

Describe the contract required for cooperative `super()` calls.

QA-6

How should initialization work across a multiple-inheritance hierarchy?

QA-7

Use substitutability to choose composition or inheritance.

QA-8

Explain why implicit special-method lookup differs from ordinary attribute access.

QA-9

Design symmetric cross-type equality using `NotImplemented`.

QA-10

Define a safe equality and hashing policy for a domain value object.

QA-11

What does a dataclass generate, and which domain concerns remain manual?

QA-12

How do inherited defaults and keyword-only fields affect dataclass constructors?

QA-13

Why is `default_factory` the correct tool for mutable dataclass defaults?

QA-14

How would you use `__post_init__` without hiding dangerous construction side effects?

QA-15

Differentiate `ClassVar`, `InitVar`, and ordinary dataclass fields.

QA-16

What level of immutability does a frozen dataclass actually provide?

QA-17

When, if ever, is `unsafe_hash` defensible?

QA-18

Evaluate slots for memory, inheritance, serialization, and tooling compatibility.

QA-19

What inheritance constraints make manual `__slots__` difficult?

QA-20

Use descriptor precedence to explain property behavior and API design.

QA-21

Compare structural Protocols with behavioral runtime contracts.

QA-22

Compare ABCs and Protocols for a library extension point.

QA-23

Explain the semantic difference between replacement and raw cloning.

QA-24

How would you evolve a dataclass without breaking positional class patterns?

QA-25

Build an object-model decision process from domain invariants.