Pattern

Object-oriented design

Model real-world entities and their interactions as classes with clear ownership, before any scheduling or persistence logic goes on top.

What it is

Object-oriented design questions test whether you can turn a physical or game-like system — an elevator bank, a parking lot, a game board — into a small set of classes where each one owns a specific piece of state and exposes the operations that change it, with the relationships between classes (a lot has floors, a floor has spots, a spot holds a vehicle) mirroring the real relationships in the domain. The interviewer is watching for whether responsibilities land in the right place — should the "assign a spot" logic live on the lot, the floor, or a separate allocator — more than for any specific algorithm.

When it applies

Tells in the problem

The classic mistake

Putting one entity's logic directly inside another entity's class out of convenience — deciding which spot to assign inside the Vehicle class, or which floor to send a car to inside the Car class — because it's the first place that came to mind, rather than giving that responsibility its own object (an allocator, a scheduler) that both sides depend on, is the error that comes up most. This muddies the design the moment the rule needs to change (a different allocation policy, a different scheduling strategy), since now it's tangled inside a class that has nothing conceptually to do with the decision. Catch it by asking, for every method you add, "is this genuinely this object's own responsibility, or am I just putting it wherever was convenient" — a class that manages another class's decision usually belongs somewhere else.

Questions to start with

All 3 object-oriented design questions

Problem statement, examples and hints are free on every page; the worked approach, solution and tests are in the company guides.

Free starter pack

13 must-tier questions with full solutions

Sign in with an email — no purchase — and read them in the full reader.

No password, no spam. One sign-in email; you can read the pack in the full reader.