Software Engineer Interview Questions & Answers (2026)

Top 30 software engineer interview questions covering data structures, algorithms, system design, and behavioral questions.

Avg. salary
$120,000 – $220,000
Top companies
Google, Amazon, Meta
Questions covered
15+ Q&As

Practice these questions with AI mock interviews

Reading answers is good. Being grilled by an AI interviewer that follows up, pushes back, and scores your response is 10× better.

Start practicing free →

Top 15 Software Engineer Interview Questions

Q1. What is the difference between a process and a thread?

A process is an independent program with its own memory space. A thread is a unit of execution within a process that shares the process's memory. Processes are isolated; threads share heap memory but have their own stack. This makes threads faster to create and switch between, but requires synchronization to avoid race conditions.

Q2. Explain the four pillars of object-oriented programming.

The four pillars are: (1) Encapsulation — bundling data and methods together and restricting direct access; (2) Abstraction — hiding implementation details and exposing only what's necessary; (3) Inheritance — allowing a class to derive properties from a parent class; (4) Polymorphism — the ability for objects of different types to be treated as the same type through a common interface.

Q3. What is the time complexity of quicksort, and when does it degrade?

Quicksort has average O(n log n) time complexity and worst-case O(n²) when the pivot is consistently the smallest or largest element — this typically happens on already-sorted input with a naive pivot selection. To mitigate this, use median-of-three pivot selection or random pivot. Space complexity is O(log n) for the recursive call stack.

Q4. How does a hash map work internally?

A hash map stores key-value pairs. When inserting, the key is run through a hash function that produces an integer index into an underlying array. If two keys hash to the same index (collision), common strategies are chaining (a linked list at each bucket) or open addressing (probing adjacent slots). Java's HashMap uses chaining and converts buckets to balanced trees (O(log n)) when they exceed 8 entries.

Q5. What is a deadlock and how do you prevent it?

A deadlock occurs when two or more threads are each waiting for a resource held by the other, creating a circular dependency. Prevention strategies: always acquire locks in a consistent global order, use lock timeouts, prefer lock-free data structures, or use a single resource manager.

Q6. Describe the CAP theorem.

CAP states that a distributed system can guarantee at most two of three properties: Consistency (every read returns the most recent write), Availability (every request receives a response), and Partition Tolerance. Since network partitions always occur in practice, real systems must choose between CP (e.g., HBase) or AP (e.g., Cassandra).

Q7. What is the difference between SQL and NoSQL databases?

SQL (relational) databases use structured tables, enforce schemas, and support ACID transactions. NoSQL databases offer flexible schemas, horizontal scalability, and high throughput. Examples: PostgreSQL vs MongoDB, MySQL vs Redis.

Q8. How would you design a URL shortener like bit.ly?

Key components: (1) unique ID generator (base62 encode a counter or UUID), (2) key-value store mapping short code to long URL (Redis cache + database), (3) redirect service returning 301/302 responses. At scale, add CDN caching, rate limiting, analytics pipeline via async queue, and geographic distribution.

Q9. What is a REST API and what are its constraints?

REST is an architectural style with six constraints: client-server separation, statelessness, cacheability, uniform interface (standard HTTP methods + status codes), layered system, and optional code-on-demand. RESTful APIs use resources as URLs, HTTP verbs for actions, and typically communicate in JSON.

Q10. What are SOLID principles?

SOLID: Single Responsibility (one reason to change), Open/Closed (open for extension, closed for modification), Liskov Substitution (subtypes must be substitutable for their base type), Interface Segregation (prefer narrow interfaces), and Dependency Inversion (depend on abstractions, not concretions).

Q11. How does garbage collection work in Java?

Java's GC manages memory automatically using generational collection: short-lived objects go to Eden, surviving objects are promoted to Survivor then Old Gen. The GC identifies unreachable objects via reachability analysis from GC roots. Modern JVMs (G1, ZGC, Shenandoah) minimize stop-the-world pauses using concurrent collection.

Q12. What is Big O notation and why does it matter?

Big O notation describes the upper bound of an algorithm's time or space growth relative to input size, ignoring constants. O(1) is constant, O(log n) logarithmic, O(n) linear, O(n²) quadratic. A O(n²) algorithm processing 1M records is a billion operations vs O(n log n)'s 20M — the difference between 10 seconds and 0.1 seconds.

Q13. Describe the difference between synchronous and asynchronous programming.

Synchronous code executes line by line — each operation blocks until complete. Asynchronous code allows the program to continue while waiting for a long operation (I/O, network) to finish. Async patterns: callbacks, Promises, async/await (JavaScript), CompletableFuture (Java), asyncio (Python). Async is critical for I/O-bound tasks.

Q14. How would you optimize a slow database query?

First, use EXPLAIN/EXPLAIN ANALYZE to understand the query plan. Common fixes: add indexes on WHERE/JOIN/ORDER BY columns; avoid SELECT *; rewrite subqueries as JOINs; use query caching; paginate with cursor-based pagination; consider materialized views for aggregations; partition large tables; review N+1 query patterns in ORM code.

Q15. Tell me about a time you dealt with a production outage.

Structure with STAR: Situation (system context and what broke), Task (your role), Action (triage, diagnosis, mitigation, fix), Result (time to recovery, lessons, post-mortem). Interviewers want to see: calm under pressure, systematic debugging, clear communication, and blameless post-mortems.

Related interview guides

Ready to turn preparation into offers?

Try Preciprocal free — no credit card required