Software Engineer Interview Questions and Answers
Software engineering interviews usually combine a recruiter screen, one or more coding rounds, a system design discussion for mid-level and senior roles, and a behavioral round. Interviewers are judging how you reason through problems out loud, how you trade off simplicity against scale, and whether you would be a dependable teammate on a production codebase.
What interviewers want
- Clear problem-solving: you clarify requirements, state assumptions, and talk through an approach before writing code
- Working knowledge of data structures and complexity, including when a hash map, heap, or tree is the right tool
- Code that is readable, tested, and handles edge cases such as empty input, duplicates, and very large values
- Practical system design judgment: caching, databases, queues, and failure modes, sized to realistic traffic
- Ownership of production code, including debugging incidents, writing postmortems, and improving reliability
- Collaboration habits such as giving and receiving code review feedback and explaining technical decisions to non-engineers
Questions and sample answers
-
Behavioral
1. Tell me about a bug in production that you were responsible for fixing.
Why they ask: They want to see how you behave under pressure and whether you fix root causes rather than symptoms.
How to answer: Use STAR and spend most of your time on how you diagnosed the issue: logs, metrics, reproducing it, narrowing the cause. Finish with what you changed to stop the same class of bug happening again, such as a test, alert, or process fix.
Show sample answer
At my last company, checkout requests started timing out for about 8% of users after a Friday deploy. I was on call, so I rolled back first to stop the bleeding, then compared traces between versions. A new ORM query was loading every line item for an order one at a time, an N+1 problem that only showed up on large carts. I rewrote it as a single join, added a test with a 200-item cart, and added a query-count check to our CI for that endpoint. Timeouts dropped to zero, and I wrote a short postmortem that led the team to add database query metrics to our standard dashboards.
-
Technical
2. What is the difference between a process and a thread?
Why they ask: It checks foundational operating systems knowledge that affects how you reason about concurrency and performance.
How to answer: Explain memory isolation, cost of creation and context switching, and the consequences for shared state. Give a practical example of when you would choose one over the other.
Show sample answer
A process is an independent program in execution with its own virtual address space, file handles, and resources. Threads live inside a process and share its memory and handles, but each has its own stack and registers. Because threads share memory, they are cheaper to create and communicate faster, but you need locks or other synchronization to avoid race conditions. Processes are isolated, so a crash in one does not take down another, which is why browsers often run tabs as separate processes. In Python, for CPU-bound work I would usually reach for multiple processes because of the global interpreter lock, while threads are fine for I/O-bound tasks like network calls.
-
Technical
3. How would you find whether any two numbers in an array add up to a target value?
Why they ask: This is a classic warm-up that shows whether you can move from a brute-force solution to an efficient one and analyse complexity.
How to answer: Start by clarifying constraints such as sorted input, duplicates, and whether you need indices. State the O(n squared) brute force, then improve it with a hash set or two pointers and give time and space complexity for each.
Show sample answer
First I would confirm whether the array is sorted and whether I need the indices or just a yes or no. The brute force checks every pair, which is O(n squared) time. A better approach is one pass with a hash set: for each number, I check whether target minus that number is already in the set; if so, I have a pair, otherwise I add the current number. That is O(n) time and O(n) space. If the array were already sorted and memory was tight, I would use two pointers from each end, moving them inward based on whether the sum is too big or too small, for O(n) time and O(1) extra space.
-
Technical
4. Design a URL shortening service.
Why they ask: System design questions show how you scope a problem, estimate load, and make sensible trade-offs between components.
How to answer: Clarify functional requirements and rough scale, then sketch the API, data model, ID generation, storage, and caching. Discuss bottlenecks and trade-offs rather than listing technologies.
Show sample answer
I would start by confirming requirements: create a short link, redirect quickly, maybe custom aliases and expiry. Assuming around 100 million new links a month, reads will far outnumber writes, perhaps 100 to 1. For IDs I would base62-encode a unique number from a distributed counter or pre-allocated ranges, which gives short codes without collision checks. Mappings go in a key-value store keyed by short code. Because redirects dominate, I would put a cache like Redis in front, and possibly a CDN. Redirects would use a 302 if we need click analytics, with click events pushed to a queue and processed asynchronously so they never slow down the redirect path.
-
Behavioral
5. Describe a time you disagreed with a teammate about a technical approach.
Why they ask: Engineering is collaborative, and they want to know you can disagree constructively and commit once a decision is made.
How to answer: Pick a real disagreement with genuine trade-offs on both sides. Show that you used data or a small experiment to resolve it, and that the relationship stayed healthy whatever the outcome.
Show sample answer
A senior colleague wanted to introduce Kafka for a new notifications feature, while I thought our existing Postgres-backed job queue would be enough. Rather than argue in the pull request, I suggested we write down expected volume and failure requirements. Our projections showed about 50 jobs per second at peak, well within what the current queue handled. I also acknowledged his point that we would need ordering guarantees later. We agreed to ship on the existing queue behind an interface so we could swap it out. The feature launched two weeks earlier than the Kafka plan, and a year later volume still had not justified the migration.
-
Technical
6. What happens when you type a URL into a browser and press Enter?
Why they ask: It tests breadth across networking, the web stack, and browser rendering, and shows how deep you can go on request.
How to answer: Walk through the steps in order and keep each concise, then offer to go deeper on any layer. Mention caching at each stage, because that is where real-world performance work happens.
Show sample answer
The browser first parses the URL and checks its own cache. It then resolves the domain through DNS, checking the browser, operating system, and resolver caches before querying name servers. With an IP address, it opens a TCP connection, or QUIC for HTTP/3, and performs a TLS handshake for HTTPS. It sends the HTTP request, which may pass through a CDN or load balancer before reaching an application server that builds the response. The browser parses the HTML into the DOM, fetches CSS, JavaScript, and images, builds the render tree, lays out the page, and paints it. I am happy to go deeper on any of those steps.
-
Situational
7. You are given a large legacy codebase with no tests and asked to add a feature. How do you approach it?
Why they ask: Most engineering work happens in existing code, so they want to see that you can make changes safely.
How to answer: Talk about understanding before changing: reading code paths, adding characterisation tests around the area you touch, and making small incremental changes. Mention talking to people who know the history.
Show sample answer
I would first find the entry points for the area I need to change and trace a real request through it, ideally with a debugger or logging. Before modifying anything, I would write characterisation tests that capture current behaviour, even if that behaviour looks odd, so I know if I break something. I would ask whoever has worked on the code longest about known landmines. Then I would make the change in small, reviewable pull requests, refactoring only what I need to make the feature fit cleanly. I would leave the area better tested than I found it, but resist rewriting large parts that are not related to the task.
-
Technical
8. When would you choose a relational database over a NoSQL database?
Why they ask: Data storage choices are hard to reverse, so they want to see principled reasoning rather than following trends.
How to answer: Compare consistency, schema, query flexibility, and scaling patterns. Tie your choice to the access patterns of a specific example.
Show sample answer
I default to a relational database such as PostgreSQL when data is highly related, I need transactions across multiple tables, or I expect ad hoc queries and reporting. Things like orders, payments, and inventory fit that well because ACID guarantees matter. I would consider a NoSQL store when access patterns are simple and known in advance and the scale or write throughput is very high, for example a key-value store for sessions or a wide-column store for time-series events. Document databases suit data with flexible, nested structure that is usually read as a whole. Many systems end up using both, with the relational database as the source of truth.
-
Role-specific
9. How do you approach code reviews, both giving and receiving them?
Why they ask: Code review is where team quality standards live, and poor review habits slow teams down or create friction.
How to answer: Describe what you look for, how you phrase feedback, and how you separate blocking issues from preferences. Show you treat feedback on your own code as useful, not personal.
Show sample answer
When reviewing, I first check whether the change does what the ticket needs and whether it is tested, then look at correctness, edge cases, and readability. I label comments as blocking or as a nitpick so the author knows what really matters, and I ask questions rather than issue commands, like asking what happens if the list is empty. I try to review within a few hours because waiting on review is a big drag on flow. When receiving feedback, I keep pull requests small so they are easy to review, explain my reasoning in the description, and if I disagree, I reply with context and am happy to take it to a quick call.
-
Situational
10. Your manager asks you to deliver a feature in half the estimated time. What do you do?
Why they ask: They want to see that you can negotiate scope honestly instead of silently cutting quality or overcommitting.
How to answer: Show that you would understand the reason for the deadline, then offer options: reduce scope, phase the delivery, or accept specific, named risks. Avoid simply saying yes or no.
Show sample answer
I would first ask what is driving the date, because a customer launch is different from an internal milestone. Then I would break the feature into pieces and identify the smallest version that delivers the core value. For example, I might suggest shipping with a manual admin process instead of a full self-service UI, then adding the UI in the next sprint. I would be explicit about what we would not do, such as load testing, and what risk that creates. That gives my manager a real choice between scope, time, and risk instead of a promise I cannot keep.
-
Behavioral
11. Tell me about something technical you learned recently on your own.
Why they ask: Technology changes quickly, and they want evidence that you keep learning and apply what you learn.
How to answer: Choose something relevant to the role, explain why you learned it, and describe how you applied it. Concrete outcomes beat a list of courses.
Show sample answer
Last year our team kept hitting confusing performance problems in our React app, so I spent a few weekends learning how the browser rendering pipeline and React reconciliation actually work, using the official docs and the Chrome performance profiler. I found that a context provider near the root was re-rendering about 300 components on every keystroke in a search box. I split the context and memoised a few expensive lists, which cut input lag from roughly 200 milliseconds to under 30. I then ran a 30-minute lunch session for the team on reading profiler flame charts, and two other engineers found similar issues in their areas.
-
Role-specific
12. How do you decide what to test and how much?
Why they ask: Testing strategy shows judgment about risk, maintainability, and speed of delivery.
How to answer: Explain the testing pyramid in practical terms and how you weigh risk. Mention that tests should give confidence to change code, not just raise a coverage number.
Show sample answer
I aim for tests that let the team change code confidently. Most of my tests are fast unit tests around business logic, especially anything involving money, permissions, or date handling, because bugs there are costly. I add integration tests for boundaries like database queries and external APIs, and a small number of end-to-end tests for the critical user journeys, such as sign-up and checkout. I do not chase 100% coverage; testing trivial getters adds maintenance cost without much value. When I fix a bug, I always write a test that reproduces it first, so it cannot quietly return.
Questions to ask the interviewer
- What does a typical path from a merged pull request to production look like here, and how long does it take?
- How is on-call organised, and what happened in the last significant incident?
- What is the biggest technical debt the team is carrying, and is there time set aside to address it?
- How do engineers here influence what gets built, beyond implementing tickets?
- What would you expect someone in this role to have delivered by the end of their first six months?
Common mistakes
- Starting to code immediately without clarifying the problem, constraints, or edge cases
- Going silent while thinking; interviewers cannot give credit for reasoning they cannot hear
- Naming technologies in system design without explaining why they fit the requirements
- Claiming sole credit for team projects or being unable to explain the parts you say you built
- Not testing your solution with a simple example and an edge case before saying you are done
Ready to apply? Browse jobs and search for “software engineer”, update your resume and write a cover letter.