Stop 15 · Portfolio & Interview PrepTopics · 7/10

Low-Level Design Questions

Part of the Java Roadmap

In short

"Design a parking lot" or "design BookMyShow" in 45 minutes. LLD rounds check whether your Java classes are clean, extensible and sensible, which is exactly what you'll write every day on the job.

Low-level design rounds ask you to design classes for systems like a parking lot, library or BookMyShow-style booking in Java. Interviewers check your use of OOP, SOLID, design patterns and clean method contracts.

The jaadu in a parking attendant's vest stands in a multi-level car park, directing a bike, a car and a big truck into differently sized spots.

Think of it like this

The mall parking manager

The parking manager at a big mall in Gurugram thinks in parts: floors, spots of different sizes, vehicles, tickets, payment counters. Each part has a clear job, and adding EV charging spots next year shouldn't mean rebuilding the whole basement. That's what interviewers want from your class design.

The big ideas

What you need to know

SOLID

Single responsibility, open/closed, Liskov, interface segregation, dependency inversion. Name them when your design follows them.

Useful patterns

Strategy for pricing, Factory for creating vehicles or spots, Singleton sparingly, Observer for notifications.

Enums and interfaces

Use enums for fixed types like SpotSize, and interfaces where behaviour varies.

Concurrency

Mention how you'd stop two threads from booking the same spot or seat, for example with synchronized or a database lock.

How it works

A repeatable way to answer

  1. 1

    Clarify

    Ask about vehicle types, number of floors, payment, and what's out of scope.

  2. 2

    Nouns to classes

    ParkingLot, Floor, Spot, Vehicle, Ticket, PricingStrategy.

  3. 3

    Relationships

    A lot has floors, a floor has spots, a ticket links a vehicle to a spot.

  4. 4

    Key methods

    park(vehicle) returns a Ticket, unpark(ticket) returns the fee.

  5. 5

    Extend and discuss

    Patterns used, thread safety for two cars taking the same spot, and how to add new vehicle types.

See it in code

Walk through the code

java
1import java.time.*;2import java.util.*;3 4enum SpotSize { SMALL, MEDIUM, LARGE }5 6sealed interface Vehicle permits Bike, Car, Truck {7    String number();8    SpotSize needs();9}10record Bike(String number)  implements Vehicle { public SpotSize needs() { return SpotSize.SMALL; } }11record Car(String number)   implements Vehicle { public SpotSize needs() { return SpotSize.MEDIUM; } }12record Truck(String number) implements Vehicle { public SpotSize needs() { return SpotSize.LARGE; } }13 14record Ticket(String id, Vehicle vehicle, int spotId, Instant entry) {}15 16interface PricingStrategy { long fee(Ticket t, Instant exit); }17 18class HourlyPricing implements PricingStrategy {19    public long fee(Ticket t, Instant exit) {20        long hours = Math.max(1, Duration.between(t.entry(), exit).toHours());21        return hours * 40;   // ₹40 per hour22    }23}24 25class ParkingLot {26    private final Map<SpotSize, Deque<Integer>> free = new EnumMap<>(SpotSize.class);27    private final PricingStrategy pricing;28 29    ParkingLot(PricingStrategy pricing) {30        this.pricing = pricing;31        for (SpotSize s : SpotSize.values()) free.put(s, new ArrayDeque<>());32    }33 34    void addSpot(SpotSize size, int spotId) { free.get(size).push(spotId); }35 36    synchronized Optional<Ticket> park(Vehicle v) {37        Integer spot = free.get(v.needs()).poll();38        if (spot == null) return Optional.empty();39        return Optional.of(new Ticket(UUID.randomUUID().toString(), v, spot, Instant.now()));40    }41 42    synchronized long unpark(Ticket t) {43        free.get(t.vehicle().needs()).push(t.spotId());44        return pricing.fee(t, Instant.now());45    }46}

1/5A sealed interface with records: a closed set of vehicle types, each knowing its spot size.

A compact Java 21 sketch. In the interview, talk through it before writing all of it.

Save yourself the pain

Common mistakes

Oops

Starting to code before asking any questions.

Do this instead

Spend the first five minutes clarifying requirements and listing classes. It's part of what's being judged.

Oops

One giant ParkingLot class that does everything.

Do this instead

Split responsibilities: pricing, spot allocation and tickets each get their own type.

Oops

Forcing every design pattern you know into the answer.

Do this instead

Use a pattern only when it solves a real need, and say why you chose it.

Your mission

Three classic designs

~120 min

Quick check

Which pattern lets you change how parking fees are calculated without editing ParkingLot?

Go deeper

  1. 1Practise designing a parking lot: clarify requirements, list classes, then write key methods.
  2. 2Draw a simple class diagram before you code.
  3. 3Explain which design patterns you used and why.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge