Low-Level Design — 50 Q&A

All 50 LLD interview questions in question-and-answer form · foundations, OOP, SOLID, design patterns, UML, and database-level design.
In self-test mode, tap a question to reveal its answer.

How to use: Click Hide answers to enter self-test mode — each question collapses, and you tap it to check yourself after answering aloud. Toggle back to read straight through, or Print for a paper copy. Anything you can’t reconstruct from memory is a weak spot to revisit.

Part 3 · Low-Level Design (50 Questions)

Foundations

L1What is the purpose of Low-Level Design?

It converts a high-level design into detailed, implementable components — class structures, object relationships, APIs, and internal logic — before coding, removing ambiguity and keeping the system scalable and maintainable.

A Parking Lot system defines Car, ParkingSpot, and ParkingLot classes and their relationships.
L2Why is LLD important?

It turns architecture into implementation-ready modules, giving a clear structure, reducing errors, and improving code quality by defining object interactions and APIs before coding.

In a ride-sharing app, LLD defines how Driver, Rider, RideRequest, and Payment interact.
L3Why is modular design important?

Splitting a system into small, independent, single-responsibility modules makes it easier to debug, test, and extend, and lets teams work in parallel.

An e-commerce app with separate User, Inventory, Payments, and Orders modules.
L4What factors influence the choice of data structures?

Access patterns, time-complexity needs, memory constraints, concurrency, and scalability.

A cache uses a HashMap for O(1) lookups; a message system uses a Queue to preserve order.
L5Which data structures are common in LLD?

Arrays, linked lists, stacks, queues, hash maps, trees, graphs, and heaps — chosen by lookup speed, insertion/deletion, ordering, and scalability.

A messaging app uses queues for processing, hash maps for user lookup, and graphs for social connections.
L6What factors guide choosing an algorithm?

Data size, distribution, memory availability, stability, parallelizability, and whether the work is in-memory or on disk.

Data too big for RAM calls for external merge sort; in-memory data suits QuickSort or MergeSort.

Object-oriented programming

L7What are the four pillars of OOP?

Encapsulation (bundle data, hide internals), Abstraction (expose only essentials), Inheritance (reuse via is-a), and Polymorphism (one interface, many behaviors) — improving reusability, flexibility, security, and maintainability.

L8What is Object-Oriented Design and why does it matter?

Modeling a system as objects and classes and their interactions, producing modular, reusable, scalable, and maintainable software.

A banking app with Account, Customer, and Transaction classes.
L9Abstraction vs encapsulation?

Abstraction hides complexity, exposing only essential functionality through interfaces/abstract classes. Encapsulation hides data, restricting access via private fields with getters/setters.

You drive a car without knowing the engine (abstraction), while the engine’s internals are protected (encapsulation).
L10Inheritance vs composition?

Inheritance is “is-a” (a subclass acquires a parent’s behavior); composition is “has-a” (built from other objects). Prefer composition — more flexible and loosely coupled than deep inheritance trees.

A Car has-an Engine (composition); a Dog is-an Animal (inheritance).
L11What is polymorphism?

The same method or interface behaving differently by context — compile-time (overloading) or runtime (overriding) — enabling generic, reusable code.

A single payment() method behaves differently for Credit Card, UPI, and PayPal.
L12Interface vs abstract class?

An interface is a pure contract (methods only, multiple inheritance); an abstract class can hold partial implementation and shared state. Use an interface for a behavior contract, an abstract class when subclasses share state/logic.

A Vehicle interface defines start()/stop(); an abstract Vehicle class adds shared speed and fuelType.
L13Association vs aggregation vs composition?

Relationships differing in ownership strength: association is a loose “uses,” aggregation is weak ownership (child lives independently), composition is strong ownership (child dies with the parent).

Teacher–Student (association), Department–Employees (aggregation), Car–Engine (composition).
L14What is the role of interfaces in LLD?

They define a contract so components communicate via abstraction rather than concrete implementations, enabling multiple implementations, dependency inversion, and easy mocking in tests.

A Notification interface with Email, SMS, and Push implementations swaps with no client changes.

Design principles

L15What are the SOLID principles?

SRP — one reason to change; OCP — open for extension, closed for modification; LSP — subtypes substitutable for their base type; ISP — no fat interfaces clients don’t use; DIP — depend on abstractions, not concretions. Together they yield clean, maintainable, scalable code.

L16What is DRY?

Don’t Repeat Yourself — avoid duplicated logic and keep a single source of truth.

One shared ValidationService instead of repeating validation across classes.
L17What is KISS?

Keep It Simple — build the simplest thing that works and avoid over-engineering.

A simple if-else for a small rule beats bolting on multiple patterns.
L18What is YAGNI?

You Aren’t Gonna Need It — build only what’s currently required.

Don’t add multi-gateway payment support when only UPI is needed today.
L19What is tight coupling and why avoid it?

Classes overly dependent on each other, hard to change, reuse, or test; prefer loose coupling via interfaces, abstraction, and dependency injection.

If PaymentService directly instantiates a PayPal object, swapping providers means editing the service.
L20What is Dependency Injection?

Providing a class’s dependencies from outside instead of creating them internally, giving loose coupling and testability (inject mocks).

Inject a Database into UserService via the constructor rather than instantiating it inside.
L21What are code smells and how do you fix them?

Signs of poor design — long methods, duplicated code, God classes, tight coupling, deep conditionals — fixed by refactoring: modularizing, applying patterns, better naming, and following SOLID.

A class doing auth, payment, and notifications is split by Single Responsibility.

Design patterns — concepts

L22What are design patterns and why do they matter?

Reusable, proven solutions to common object-oriented design problems, giving a shared vocabulary and improving maintainability, scalability, and flexibility.

The Factory pattern creates UPI/Card/Wallet payment objects without changing core logic.
L23What are the three types of design patterns?

Creational (Singleton, Factory, Abstract Factory), Structural (Adapter, Facade, Proxy, Decorator), and Behavioral (Observer, Strategy, Command, Chain of Responsibility).

L24When should you avoid patterns to prevent over-engineering?

When they add needless complexity to a problem a simple approach solves; use a pattern only for a real, recurring design problem.

Applying Strategy to a single fixed tax rule is overkill — a method suffices.
L25What factors matter before choosing a pattern?

The nature and complexity of the problem, how often it’s expected to change, and the impact on flexibility, performance, and maintainability.

Singleton looks easy for shared config, but testing and scalability may favor DI.
L26Can multiple patterns be combined?

Yes — they address different concerns and complement each other.

MVC uses Observer (view updates), Strategy (interchangeable logic), and Factory (object creation).
L27How do patterns help manage dependencies at scale?

They structure interactions through abstractions and indirection, reducing tight coupling and localizing changes.

Factory plus DI manage object creation and wiring in a microservices codebase.

Design patterns — specific

L28Singleton pattern?

Ensures a single instance with a global access point — used for DB connection pools, config managers, and logging. Downsides: global state (harder testing), tight coupling, reduced flexibility.

A single shared database connection object.
L29Disadvantages of Singleton?

Global state that’s hard to test and maintain, tight coupling, reduced flexibility, and difficulty mocking in unit tests — which is why DI is often better.

L30Observer pattern?

A subject maintains a list of observers and automatically notifies them on a state change — a one-to-many relationship without tight coupling.

A stock price (subject) updates all trader dashboards (observers) in real time.
L31Factory Method pattern?

Creates objects without exposing creation logic; a factory method decides the concrete class, centralizing creation and promoting loose coupling — used when the type isn’t known until runtime.

A PaymentFactory returns UPI, Card, or Wallet objects based on input.
L32Abstract Factory vs Factory Method?

Use Abstract Factory to create families of related objects that must be compatible together; Factory Method handles one product at a time.

A UI toolkit’s Abstract Factory makes matching Windows buttons + menus or Mac buttons + menus.
L33Static factory methods vs the Factory pattern?

Static factory methods are simple methods returning objects, tied to one class with no polymorphism; the Factory pattern is structured and extensible via interfaces and subclasses.

User.createUser() returns a User directly, whereas a Factory creates different User types without client changes.
L34Strategy pattern?

Encapsulates interchangeable algorithms and lets you swap them at runtime, avoiding hardcoded logic.

Payment methods (UPI/Card/PayPal) as separate strategies chosen at runtime.
L35Proxy vs Decorator pattern?

A Proxy controls access (security, lazy loading, remote); a Decorator adds behavior dynamically.

A Proxy checks permissions before file access; a Decorator adds logging or compression.
L36Chain of Responsibility pattern?

Passes a request along a chain of handlers until one handles it, decoupling sender from receiver.

An approval request flows manager → director → CEO until approved.
L37Command pattern (undo/redo)?

Encapsulates a request as an object storing what’s needed to execute and reverse it, kept in a history stack to enable undo/redo.

Text-editor typing and deleting stored as command objects enabling undo/redo.
L38Null Object pattern?

Replaces null with a do-nothing object implementing the same interface, eliminating repetitive null checks.

A NullLogger whose log() does nothing, instead of checking if (logger != null) everywhere.

UML & modeling

L39What are the commonly used UML diagrams?

Class, Sequence, Use Case, Activity, and State diagrams — visualizing structure, flow, interactions, and behavior.

For banking, a Class Diagram shows Account/Customer, and a Sequence Diagram shows a money-transfer flow.
L40What are UML behavioral diagrams?

Diagrams showing dynamic behavior — how objects interact and how the system changes over time in response to events — versus structural diagrams.

A login sequence diagram: UI → auth service → DB → back.
L41Model a sequence diagram for user login.

Time-ordered messages between components: User → Login Controller → Authentication Service → Database → back with success or failure, capturing the step-by-step message passing.

L42Model behavior with a state diagram.

Show an object’s states and the event-triggered transitions between them — its lifecycle.

A payment moves Pending → Processing → Completed/Failed based on events.

Data, DB & system-level LLD

L43How does database indexing optimize queries?

It creates an extra structure (B-tree, hash, or bitmap) so the database locates rows without a full scan, giving faster SELECTs and less disk I/O at the cost of storage and slightly slower writes.

An index on user_id jumps straight to a record.
L44What are the benefits of normalization?

Organizing tables to cut redundancy and improve integrity, making inserts, updates, and deletes reliable.

Separate Customers and Orders tables linked by a customer id, instead of repeating customer details on every order.
L45What are the principles of good database design?

Normalization, proper relationships, indexing, constraints, and suitable data types, along with scalability, security, and efficient storage.

An e-commerce schema with separate users, orders, and products tables joined by foreign keys.
L46Why is concurrency control important in multi-threaded systems?

It lets multiple threads safely access shared resources without inconsistency, preventing race conditions, deadlocks, and corrupted state.

Two simultaneous withdrawals from one account update the balance correctly.
L47How do you handle versioning and backward compatibility?

Use API versioning and controlled database migrations, keeping old versions working through gradual deprecation, feature flags, and regression testing.

Keep /api/v1/users alive while /api/v2/users adds new fields.
L48Design a secure authentication and authorization system (distributed).

Combine secure identity — OAuth 2.0, JWT, MFA, password hashing — with authorization (RBAC/ABAC) and central identity providers that validate tokens per service.

A user logs in via an identity provider, receives a JWT, and each service validates it and checks the role.
L49Design an efficient logging and monitoring system.

Use structured logging with log levels and centralized aggregation, plus dashboards and alerting on latency, CPU, and errors, and attach a correlation id per request to trace it end to end.

Microservices log with a correlation id into ELK or Grafana for tracing.
L50Design a Parking Lot (the classic LLD exercise).

Model the core classes and responsibilities: ParkingLot (holds levels), Level, ParkingSpot (compact/large/handicapped), Vehicle (Car/Bike/Truck via inheritance), Ticket, and PaymentProcessor. Apply OOP (inheritance for vehicle/spot types), Strategy (pricing), and Factory (spot/vehicle creation), and handle concurrency for spot allocation. It’s the canonical “show me your OOP + patterns” question.