Low-Level Design (Object-Oriented Design) Module 17
Machine-coding and interview practice: questions
Questions on machine-coding and interview practice: short warm-ups, then what each harder question tests, the first step of a good answer and its follow-ups.
Warm-up questions
Short questions with short answers, each answered in full.
-
Fresher
What is a seam in a design, and how does it help when a follow-up arrives?
Answered in the lesson Handling follow-up questions and extensions
-
Fresher
Why does a timed mock stop to run the sample and the tests at fixed checkpoints, such as minutes 30, 60 and 90?
A checkpoint turns "I think I am on time" into a number while there is still time to act. Running the sample shows how many commands already give the expected answer, and running the tests shows whether anything that worked has broken. At minute 30 the number says whether the happy path is done; at minute 60, whether every rule exists and is tested; at minute 90, whether the follow-up kept everything green. Each result decides the next half hour: add the guards that protect state, cut a feature that will not fit, or stop adding and start tidying. Without checkpoints, problems surface in the demo, when nothing can be done about them. The runs also give the review its evidence, because a score backed by a run is more honest than a feeling.
From the lesson A timed machine-coding mock, step by step
-
Fresher
What are the stages of a 45-minute object-oriented design discussion, and roughly how long does each take?
Five stages, each ending with something written down. Clarify for about 5 minutes: ask about rules, and write numbered requirements, an out-of-scope list and assumptions. Model for about 15: the classes and the one rule each owns, with the options you rejected. Diagrams for about 10: a class diagram with multiplicities and one state or sequence diagram for the trickiest behaviour. Key code for about 10: the method that holds the hardest rule, with its tests named. Follow-ups for the last 5: where each requested change lands and what stays untouched. The minutes are a budget rather than a law. A small prompt may need less modelling and more code, but every stage still gets at least a line, because a skipped stage is where a missed rule hides.
From the lesson Self-mock: object-oriented design discussion
Questions with model answers
What each question tests, the first step of a good answer and the follow-ups to expect.
-
Mid to senior
Your hotel booking design stores each check-in as a UTC instant. Follow-up: "Cancellation is free until 18:00 on the day before arrival, in the hotel's own time zone." Where does the rule go, what stays untouched, and which tests prove it?
- What it tests
- Placing a time rule with the owner of the related decision, keeping local wall-clock times and instants apart, and choosing boundary tests around the cut-off and a clock change.
- First step
- Restate it as a numbered rule with its edge: cancelling is free while the current instant is before 18:00 local time on the day before arrival, in the hotel's zone. Then name who decides refunds today, such as a tariff or a cancellation policy, and say the cut-off is computed there from the hotel's zone, not as a fixed 24-hour offset.
- Follow-ups
-
- The hotel's zone moves its clocks back an hour during the night before arrival. What does your cut-off do?
- Some hotels want their cut-off at 12:00 instead. Where does that setting live?
- A guest cancels at 17:59:59 local time. Which instants do your tests use, and why?
From the lesson Handling follow-up questions and extensions
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; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.
Passes can’t be bought right now, so the model answers can’t be opened at the moment. If you have a pass, enter your licence key.
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 3 minutes
-
Mid to senior
Your parking lot saves tickets to a file after every change and prints each ticket after taking the spot. Follow-up: "The power fails after the ticket is saved but before it is printed." What happens after the restart, and what would you change?
- What it tests
- Reasoning about a crash between a state change and a side effect, making the side effect safe to repeat, and keeping the invariant of one ticket per spot.
- First step
- Walk through the state after the restart: the file says a spot is held by a ticket nobody has, the driver is still at the barrier, and the next car will not get that spot. Then say what must be true afterwards: the driver can get the same ticket again, and nothing is held or charged twice.
- Follow-ups
-
- Why not print first and save afterwards?
- The driver drove away instead of waiting. How does the spot ever come back?
- How would you test this without pulling a plug?
From the lesson Handling follow-up questions and extensions
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
Your parking-lot design now serves 2,000 lots: 50,000 entries an hour across all of them, and at most 400 an hour at the busiest one. The interviewer asks what changes. What stays in your low-level design, what moves to high-level design, and what do the numbers tell you?
- What it tests
- Estimating load before scaling, keeping the model of one lot intact, choosing what to partition by, and naming the invariant that the shared store must enforce.
- First step
- Turn the numbers into rates first: 50,000 entries an hour is about 14 a second for the whole product, and 400 an hour is one entry every 9 seconds at the busiest lot. Then say what that means: the rules of one lot stay in one object, and the real question is where each lot's data lives and who enforces one ticket per spot.
- Follow-ups
-
- Would you give each lot its own database?
- The busiest lot opens a second entrance with four more gates. Does anything change?
- Reports must show occupancy across all lots every minute. Where do they read from?
From the lesson Handling follow-up questions and extensions
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Fresher to mid
At minute 60 of a 90-minute round your happy path works, three refusals are missing, there are no tests, and the interviewer will ask for a change at minute 75. How do you spend the last 30 minutes?
- What it tests
- Prioritising under a deadline: guards that protect state, one golden test, time kept for the follow-up and the demo, and saying out loud what is cut.
- First step
- Split the 30 minutes before touching code: about 10 for the three refusals, each with a test, 5 for a golden test of the sample, 10 kept free for the follow-up and 5 for the demo. Say the split out loud, so the interviewer knows what will be finished and what will not.
- Follow-ups
-
- The golden test fails on a line you do not understand. Do you fix it or move on?
- The follow-up arrives at minute 70 instead of 75. What do you drop?
- Is it ever right to skip tests altogether?
From the lesson A timed machine-coding mock, step by step
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
After your demo of a visitor gate-pass program, the interviewer asks: "What would you do with two more hours?" What makes a strong answer, and what makes a weak one?
- What it tests
- Ranking work by risk and by the requirements, naming each change with its place in the code, and estimating the effort honestly.
- First step
- Start from the not-done list and rank it by the risk of a wrong answer, not by what is interesting: guards and edge cases first, then the missing requirements, then structure. Give each item its place in the code and a time estimate, so that the two hours add up.
- Follow-ups
-
- Would you add a database?
- Where does concurrency come in your list?
- The interviewer says the code is hard to read. Does that change your order?
From the lesson A timed machine-coding mock, step by step
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
You finished a practice mock: every sample line matches, nine tests pass, and the follow-up took edits in four places. How do you score it on six areas from 1 to 4, and what evidence would move a 2 to a 3?
- What it tests
- Applying a rubric from evidence rather than feelings, keeping what the code shows apart from what was said, and turning the lowest scores into the next practice focus.
- First step
- Score each area only from evidence you can point to: the run of the sample, the tests, the diff of the follow-up and the not-done list. Coverage and correctness look like 3s; a follow-up spread over four places is a 2 for extensibility. Then name, for each 2, the one change that would make it a 3.
- Follow-ups
-
- Your score and a friend's differ by two points in one area. What do you do?
- Should finishing early raise any score?
- How do you track scores across eight mocks?
From the lesson A timed machine-coding mock, step by step
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes
-
Fresher to mid
In a design discussion the interviewer says almost nothing for the first ten minutes. How do you keep the discussion useful, and how do you check that you are on track?
- What it tests
- Driving a discussion with checkpoints, turning silence into explicit decisions, and inviting correction early without waiting for permission.
- First step
- Make the silence productive: say each decision as a numbered assumption, and ask for a yes or a no at the end of each stage, for example "I have six requirements; before I model, is anything missing or out of scope?" A question like that every few minutes costs seconds and catches a wrong turn early.
- Follow-ups
-
- At minute 20 the interviewer says "that's not what I meant". What do you do?
- Should you ask whether you are doing well?
- How do you practise this alone?
From the lesson Self-mock: object-oriented design discussion
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
Members of a tool library reserve a tool type for a range of days. How would you model reservations so that overlaps, early returns and late returns are all handled? Name the classes and the one rule each owns.
- What it tests
- Putting range logic in a small value, choosing what availability is computed from, and handling a late return that blocks the next reservation.
- First step
- Fix the meaning of a range first: days run up to an end that is not included, so days 3 to 5 and days 6 to 7 do not overlap. Give that comparison to a small Days value, keep reservations with an item and a status, and decide what an item that is still out means for the next booking.
- Follow-ups
-
- An item comes back two days early. Can someone else take it?
- The borrower before is late, and the next member is at the counter. What happens?
- Reservations grow to 50,000 a year. Does your model change?
From the lesson Self-mock: object-oriented design discussion
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
Ten minutes remain in a 45-minute discussion. You have a class diagram but no code, and the interviewer asks for "the key code". What do you write, and what do you leave as signatures?
- What it tests
- Choosing the method that carries the hardest rule, writing it in full with its boundary cases, and leaving the rest as signatures with their errors.
- First step
- Name the hardest rule first, the one most likely to be wrong, such as choosing a free item for a range, and write that method completely. Everything else gets a signature with what it returns and which refusals it raises, and the tests are named rather than written.
- Follow-ups
-
- Which language do you write it in?
- The interviewer asks you to run it in your head. How?
- Halfway through you find that a class is missing. Do you go back to the diagram?
From the lesson Self-mock: object-oriented design discussion
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