Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Low-Level Design (Object-Oriented Design) Module 11

Case studies: everyday machines interview questions

Interview questions on “Case studies: everyday machines”: warm-ups, then what each harder question tests and how a good answer starts.

8 questions: 3 warm-ups and 5 with model answers · Levels: Fresher to staff

Warm-up questions

Short questions with short answers, each answered in full.

  1. Fresher to mid

    Should ParkingLot be a singleton?

    Answered in the lesson Low-level design: parking lot (the model)

  2. Fresher to mid

    Should Car, Motorcycle and Van be subclasses of Vehicle?

    Answered in the lesson Low-level design: parking lot (the model)

  3. Fresher to mid

    Why does a signal plan need an all-red interval between phases when the amber already warns drivers?

    Answered in the lesson Low-level design: traffic signal controller

Questions with model answers

What each question tests, the first step of a good answer and the follow-ups to expect.

  1. Mid to senior

    Your parking lot has two entry gates, and once in a while both send a car to the same spot. Explain how that can happen, then fix it twice: in the in-memory design, and when the spots live in a relational database.

    What it tests
    Spotting a check-then-act race, deciding exactly what one lock must cover, keeping slow work outside it, and the database form of an atomic claim.
    First step
    Write the entry out as steps and interleave two gates: both look, both see the same spot available, both claim it. The bug is the gap between looking and claiming. Then say which steps must become one: the plate check, the choice of a spot and the claim.
    Follow-ups

    From the lesson Low-level design: parking lot (the model)

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.

    Opening the model answers with your pass…

    Model answers open with any MySmartCoPilot pass.

    • Pro pass · 1 week₹79$2.99
    • 30 days₹179$5.99
    • 1 year₹1,699$45

    One payment; nothing renews unless you choose to. The price shown is the total you pay: no fees or charges are added at checkout.

    It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 4 minutes
  2. Mid to senior

    The operator raises parking prices at noon. How does your design price a car that entered at 10:00 and leaves at 14:30, and what changes in your classes if the business decides to split each stay at the change instead?

    What it tests
    Keeping the version of a rule with the record it prices, what each choice does to caps and rounding, and changing a policy behind its interface without editing callers.
    First step
    Name the three possible rules: the tariff at entry, the tariff at exit, or a split at the moment of the change. Choose one with a reason, then show where the tariff is stored, because that decides what a receipt can explain later.
    Follow-ups

    From the lesson Low-level design: parking lot (the model)

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 4 minutes
  3. Mid to senior

    Your controller switches to the evening timing plan exactly at 17:00. Soon after it goes live, a near miss is reported at 17:00:00. What could have gone wrong, and how do you change plans safely?

    What it tests
    Seeing that a plan change is a transition with its own safety rules, checking transitions rather than pairs, and choosing the moment a new plan may start.
    First step
    Ask what the junction was showing at 16:59:59. If a phase other than the new plan's first was green, switching at once cut that green to red with no amber and released crossing traffic with no all red. Then say when a switch is safe: at the end of a cycle, after its all red.
    Follow-ups

    From the lesson Low-level design: traffic signal controller

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  4. Mid to senior

    An ambulance approaches from the east while north-south has 25 seconds of green left and a pedestrian has pressed the button. Walk through what the junction shows, second by second, and say what the controller must never cut short.

    What it tests
    Preemption as a state with priority, the intervals that are never shortened, how waiting requests are kept, and how the cycle resumes.
    First step
    Separate what may be cut from what may not. The north-south green may end at once; its amber and the all red that follows keep their full length. Count the seconds from the call to the east green, then say what happens to the pedestrian's request.
    Follow-ups

    From the lesson Low-level design: traffic signal controller

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  5. Senior to staff

    A relay sticks, and one signal head keeps showing green after the controller tells it amber. How does your design notice, how quickly, and what does the junction do next?

    What it tests
    Detecting faults from what the heads really show, the value of a check independent of the controller, and a safe fault mode with a manual way out.
    First step
    Say what the controller can compare: what it told each head against what the head reports back. That catches the stuck head in the same second. Then explain what a separate monitor adds, and what the junction shows once a fault is found.
    Follow-ups

    From the lesson Low-level design: traffic signal controller

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes

All Low-Level Design (Object-Oriented Design) interview questions · The Low-Level Design (Object-Oriented Design) track

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.