Software Engineer Interview Questions for Freshers (with Answers)
Fresher software engineer interviews in India follow a predictable pattern: an online test (aptitude plus one or two coding problems), a technical round on computer science fundamentals and your projects, and an HR round. Service companies lean on fundamentals; product companies spend most of the time on data structures and algorithms.
The questions below are the ones that come up again and again. Learn the idea behind each answer rather than the wording, because the follow-up is always "why?".
Data structures and algorithms
What is the difference between an array and a linked list?
An array stores elements in contiguous memory, so reading by index is O(1) but inserting or deleting in the middle is O(n) because elements shift. A linked list stores nodes anywhere in memory joined by pointers, so insertion and deletion at a known node are O(1) but reaching the k-th element is O(n).
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, as in function calls and undo. A queue is first-in, first-out: you add at the rear and remove from the front, as in task scheduling and breadth-first search.
How does a hash map work, and what is a collision?
A hash function turns the key into an array index (a bucket), giving average O(1) insert and lookup. A collision is two keys landing in the same bucket; it is handled by chaining (each bucket holds a list or tree) or open addressing (probing for the next free slot).
Explain time complexity and Big-O with an example.
Big-O describes how running time grows with input size, ignoring constants. Linear search checks every element, so it is O(n). Binary search halves a sorted range each step, so it is O(log n).
Which sorting algorithm would you use and why?
For general use, merge sort or quicksort at O(n log n). Merge sort is stable and guaranteed O(n log n) but needs extra memory; quicksort is in-place and fast on average but O(n²) in the worst case. For nearly sorted or very small arrays, insertion sort is good.
What is the difference between BFS and DFS?
Breadth-first search explores level by level using a queue and finds the shortest path in an unweighted graph. Depth-first search goes as deep as possible using a stack or recursion and suits cycle detection, topological sort and exploring all paths.
What is recursion, and what is a base case?
Recursion is a function solving a problem by calling itself on a smaller input. The base case is the input small enough to answer directly; without it the calls never stop and the stack overflows.
How do you detect a cycle in a linked list?
Use two pointers (Floyd’s algorithm): move one a step at a time and the other two steps. If they ever meet, there is a cycle; if the fast pointer reaches null, there is none. It uses O(1) extra space.
Object-oriented programming
What are the four pillars of OOP?
Encapsulation (bundling data with the methods that use it and hiding the internals), abstraction (exposing only what the caller needs), inheritance (a class reusing and extending another) and polymorphism (one interface, different behaviour depending on the object).
What is the difference between overloading and overriding?
Overloading is several methods with the same name but different parameters in one class, resolved at compile time. Overriding is a subclass providing its own version of a parent method with the same signature, resolved at run time.
Abstract class or interface: what is the difference?
An abstract class can hold state and implemented methods and a class can extend only one. An interface is a contract of methods a class promises to implement, and a class can implement many. Use an abstract class for shared code among related classes, an interface for a capability unrelated classes share.
DBMS and SQL
What is normalization?
Organising tables to remove duplicated data and update anomalies. 1NF: atomic values, no repeating groups. 2NF: no column depends on only part of a composite key. 3NF: no non-key column depends on another non-key column.
What is the difference between a primary key and a unique key?
Both enforce uniqueness. A table has one primary key and it cannot be NULL; a table can have several unique keys and they generally allow NULL.
What are the ACID properties?
Atomicity (a transaction happens fully or not at all), consistency (it moves the database between valid states), isolation (concurrent transactions do not interfere) and durability (committed changes survive a crash).
Explain the types of joins.
INNER JOIN returns rows that match in both tables. LEFT JOIN returns all rows of the left table with matches from the right, or NULLs. RIGHT JOIN is the mirror. FULL OUTER JOIN returns all rows from both sides, matched where possible.
What is an index and when does it hurt?
An index is a sorted structure (usually a B-tree) that lets the database find rows without scanning the table. It speeds up reads on the indexed columns but slows inserts and updates and takes space, so you index columns you filter or join on, not every column.
Operating systems and networks
What is the difference between a process and a thread?
A process is a running program with its own memory space. A thread is a unit of execution inside a process that shares the process’s memory with other threads. Threads are cheaper to create and switch, but shared memory means you must handle synchronisation.
What is a deadlock?
Two or more processes each waiting for a resource the other holds, so none can proceed. It needs four conditions together: mutual exclusion, hold and wait, no preemption and circular wait. Breaking any one, for example by always acquiring locks in the same order, prevents it.
What happens when you type a URL and press Enter?
The browser resolves the domain to an IP address through DNS, opens a TCP connection (and a TLS handshake for HTTPS), sends an HTTP request, the server returns a response, and the browser parses the HTML and fetches and renders the CSS, JavaScript and images it references.
What is the difference between TCP and UDP?
TCP is connection-oriented and reliable: it orders packets, retransmits lost ones and controls congestion, so it is used for web, email and file transfer. UDP is connectionless with no delivery guarantee but lower overhead, so it is used for video calls, streaming, gaming and DNS.
How to prepare in the last two weeks
- Solve 40–50 easy and medium problems covering arrays, strings, hashing, two pointers, linked lists, stacks, trees and basic recursion. Say your approach aloud before coding.
- Revise one language properly. Interviewers forgive a narrow skill set more easily than shallow answers in five languages.
- Prepare a two-minute explanation of each project: the problem, what you built, one hard bug and what you would change.
- Write SQL by hand: joins, GROUP BY with HAVING, and "second highest salary".
- Do one timed mock test for the online assessment format of the company you are applying to.