Technology

Software Engineer Interview Questions and Answers

Software engineering interviews, especially campus placements, test computer science fundamentals: data structures, algorithms, OOP, operating systems, networks and system design. These questions cover what interviewers ask most often, with answers that explain the reasoning.

Reading answers is not the same as saying them.Practise cs fundamentals questions out loud and get a score, what you missed and a model answer for each one.
Practise free with AI

Topics interviewers ask about

Data StructuresAlgorithmsOOPSystem DesignOperating SystemsComputer NetworksDBMSCC++JavaPythonDesign Patterns

Basic cs fundamentals interview questions

Fundamentals, definitions and simple scenarios. Good for freshers and warm-ups.

1. What is the difference between an array and a linked list?

An array stores elements next to each other in memory, so access by index is O(1) and it is cache-friendly, but inserting or deleting in the middle is O(n) because elements must shift. A linked list stores nodes connected by pointers: inserting or deleting at a known node is O(1), but reaching the nth element is O(n), and each node uses extra memory for the pointer.

2. What are the four pillars of object-oriented programming?

Encapsulation keeps data and the methods that change it together and hides internal details behind a public interface. Abstraction exposes only what is essential, like an interface. Inheritance lets a class reuse and extend another class. Polymorphism lets the same call behave differently depending on the object, for example draw() on a Circle or a Square, through method overriding or overloading.

3. What is the difference between a stack and a queue?

A stack is Last In, First Out: you push and pop at the same end. It is used for the function call stack, undo features, expression evaluation and depth-first search. A queue is First In, First Out: you add at the back and remove from the front. It is used for task scheduling, buffers and breadth-first search.

4. What is Big O notation?

Big O describes how an algorithm's running time or memory grows as the input grows, usually for the worst case, ignoring constants. Common classes are O(1) for constant time like array access, O(log n) for binary search, O(n) for a single loop, O(n log n) for efficient sorting like merge sort, and O(n²) for nested loops over the same data.

Intermediate cs fundamentals interview questions

Applied problems, trade-offs and questions about your own projects.

5. How does a hash table work?

A hash function turns a key into an index in an array of buckets. Two keys can land in the same bucket (a collision), which is handled by chaining (a list per bucket) or open addressing (probing for another slot). Lookups, inserts and deletes are O(1) on average and O(n) in the worst case. When the load factor gets too high, the table resizes and rehashes all keys.

6. What are the necessary conditions for a deadlock?

Four conditions must hold together: mutual exclusion (a resource can be held by only one process), hold and wait (a process holds one resource while waiting for another), no preemption (resources cannot be taken away), and circular wait (a cycle of processes each waiting for the next). Breaking any one prevents deadlock; the most practical way is to always acquire locks in a fixed order.

7. What happens when you type a URL into a browser and press Enter?

The browser resolves the domain to an IP address through DNS, using caches first. It opens a TCP connection, or QUIC for HTTP/3, and performs a TLS handshake for HTTPS. It sends an HTTP request; the server, often behind a load balancer, returns a response. The browser parses the HTML into the DOM, fetches CSS and JavaScript, builds the CSSOM, then calculates layout and paints the page.

8. What is the difference between TCP and UDP?

TCP is connection-oriented and reliable: it guarantees delivery in order, retransmits lost packets, and controls flow and congestion. It is used for web pages, email and file transfer. UDP is connectionless with no delivery or ordering guarantees but lower latency and overhead, so it suits video calls, online games, live streaming and DNS lookups.

High level cs fundamentals interview questions

System design, deep internals, leadership and tough follow-ups.

9. Explain dynamic programming with an example.

Dynamic programming solves problems that have overlapping subproblems and optimal substructure by storing the results of subproblems instead of recomputing them. Naive recursive Fibonacci is O(2ⁿ); with memoisation (top-down) or a table built from the base cases (bottom-up) it becomes O(n). Classic DP problems include 0/1 knapsack, longest common subsequence, coin change and edit distance.

10. How would you design a rate limiter?

Common algorithms are fixed window counters (simple but bursty at window edges), sliding window logs or counters (smoother), and token bucket, which allows controlled bursts and is the most common. In a distributed system the counters live in Redis, updated atomically with INCR and EXPIRE or a Lua script, keyed by user, API key or IP. Over the limit, the API returns 429 Too Many Requests with a Retry-After header.

11. Explain the SOLID principles.

Single Responsibility: a class should have one reason to change. Open/Closed: open for extension, closed for modification. Liskov Substitution: subclasses must work anywhere the parent class does. Interface Segregation: many small, specific interfaces are better than one large one. Dependency Inversion: depend on abstractions, not concrete classes, so implementations can be swapped and tested.

12. How do you detect a cycle in a linked list?

I use Floyd's tortoise and hare: a slow pointer moves one step and a fast pointer two steps at a time. If the fast pointer reaches null, there is no cycle; if they meet, there is one. It runs in O(n) time and O(1) space. To find where the cycle starts, I move one pointer back to the head and advance both one step at a time; they meet at the start of the cycle.

Ready to test yourself?Pick your topics and level, answer by voice or text, and get instant feedback. Free.
Start a mock interview

More technology interview questions