Top Coding Interview Questions for Freshers (2025)
Landing your first software development job is one of the most exciting—and nerve-wracking—milestones of your career. The technical interview stands between you and that coveted offer letter, and knowing what to expect can make all the difference. This comprehensive guide covers the most frequently asked coding interview questions for freshers in 2025, complete with explanations, examples, and actionable preparation strategies.
Whether you’re graduating from a computer science program, finishing a coding bootcamp, or switching careers into tech, this post will help you walk into your interview with confidence.
Why Preparation Matters for Freshers

As a fresher, you don’t have years of professional experience to fall back on. Interviewers know this, so they focus on your fundamentals—how well you understand core programming concepts, how you approach problems, and whether you can write clean, working code under pressure.
According to a 2024 HackerRank developer skills report, over 73% of hiring managers consider problem-solving ability the most important factor when evaluating fresh graduates. That means drilling through common coding interview questions for freshers isn’t just helpful—it’s essential.
Here’s what most tech companies evaluate during a fresher coding interview:
- Core programming knowledge (variables, loops, functions, recursion)
- Data structures & algorithms (arrays, linked lists, sorting, searching)
- Object-oriented programming concepts
- SQL and basic database understanding
- Logical thinking and problem decomposition
Let’s dive into each category with specific questions and clear explanations.
🛒 Cracking the Coding Interview book
View on Amazon →
As an Amazon Associate, we earn from qualifying purchases.
Basic Programming Questions Every Fresher Must Know

These are the warm-up questions interviewers love to start with. They test your understanding of fundamental programming concepts and your ability to write syntactically correct code.
1. What is the difference between a compiler and an interpreter?
A compiler translates the entire source code into machine code before execution, producing an executable file. An interpreter translates and executes code line by line at runtime. Languages like C and C++ use compilers, while Python and JavaScript use interpreters (or JIT compilers).
2. Write a program to check if a number is prime.
def is_prime(n):
if n <= 1:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
print(is_prime(17)) # Output: True
Why this matters: This question tests your understanding of loops, conditionals, and basic mathematical optimization (checking up to √n instead of n).
3. Explain the difference between pass by value and pass by reference.
Pass by value: A copy of the variable is passed to the function. Changes inside the function don't affect the original variable. Pass by reference: A reference (memory address) to the variable is passed. Changes inside the function affect the original variable.
4. Write a program to reverse a string without using built-in functions.
def reverse_string(s):
reversed_str = ""
for char in s:
reversed_str = char + reversed_str
return reversed_str
print(reverse_string("hello")) # Output: "olleh"
5. What is recursion? Write a factorial program using recursion.
Recursion is when a function calls itself to solve a smaller instance of the same problem. Every recursive function needs a base case to prevent infinite recursion.
def factorial(n):
if n == 0 or n == 1: # Base case
return 1
return n * factorial(n - 1)
print(factorial(5)) # Output: 120
6. What is the difference between == and === (in JavaScript)?
== performs type coercion before comparison (loose equality), while === checks both value and type without coercion (strict equality). For example, "5" == 5 returns true, but "5" === 5 returns false.
Data Structures & Algorithm Questions

Data structures and algorithms (DSA) form the backbone of most coding interviews. Even at the fresher level, you're expected to understand fundamental data structures and know when to use them.
7. What is the difference between an Array and a Linked List?
| Feature | Array | Linked List |
|---|---|---|
| Memory Allocation | Contiguous | Non-contiguous |
| Access Time | O(1) – Direct index | O(n) – Sequential |
| Insertion/Deletion | O(n) – Shifting needed | O(1) – At head/tail |
| Size | Fixed (static arrays) | Dynamic |
| Memory Overhead | Low | Higher (pointer storage) |
8. Find the second largest element in an array.
def second_largest(arr):
first = second = float('-inf')
for num in arr:
if num > first:
second = first
first = num
elif num > second and num != first:
second = num
return second if second != float('-inf') else None
print(second_largest([12, 35, 1, 10, 34, 1])) # Output: 34
This is an O(n) solution that traverses the array only once—much more efficient than sorting.
9. Explain the difference between a Stack and a Queue.
A Stack follows LIFO (Last In, First Out)—think of a stack of plates. A Queue follows FIFO (First In, First Out)—think of a line at a ticket counter. Stacks are used in function call management and undo operations, while queues are used in scheduling and BFS algorithms.
10. Write a program to detect a cycle in a linked list.
This is a classic question that uses Floyd's Cycle Detection Algorithm (tortoise and hare approach):
def has_cycle(head):
slow = fast = head
while fast and fast.next:
slow = slow.next
fast = fast.next.next
if slow == fast:
return True
return False
11. What is the time complexity of common sorting algorithms?
You should be able to discuss Bubble Sort (O(n²)), Merge Sort (O(n log n)), and Quick Sort (O(n log n) average, O(n²) worst case). Knowing when to use each is equally important.
12. Implement Binary Search.
def binary_search(arr, target):
low, high = 0, len(arr) - 1
while low <= high:
mid = (low + high) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
low = mid + 1
else:
high = mid - 1
return -1
print(binary_search([2, 3, 4, 10, 40], 10)) # Output: 3
🛒 Introduction to Algorithms CLRS textbook
View on Amazon →
As an Amazon Associate, we earn from qualifying purchases.
Object-Oriented Programming (OOP) Questions
OOP is a cornerstone of software development, and freshers are expected to understand its four pillars thoroughly.
13. Explain the four pillars of OOP.
- Encapsulation: Bundling data and methods that operate on that data within a single class, restricting direct access to some components.
- Abstraction: Hiding complex implementation details and exposing only the necessary interface.
- Inheritance: A mechanism where a new class derives properties and behavior from an existing class.
- Polymorphism: The ability of objects to take on multiple forms—method overloading (compile-time) and method overriding (runtime).
14. What is the difference between an abstract class and an interface?
An abstract class can have both abstract and concrete methods, can maintain state (instance variables), and supports single inheritance. An interface (in Java) defines a contract with only abstract methods (pre-Java 8), supports multiple inheritance, and cannot maintain state.
15. What is the difference between method overloading and method overriding?
Overloading occurs within the same class with methods having the same name but different parameters (compile-time polymorphism). Overriding occurs in a subclass that provides a specific implementation of a method already defined in its parent class (runtime polymorphism).
16. Explain the SOLID principles briefly.
While this is more of an intermediate topic, many interviewers appreciate freshers who know SOLID:
- S – Single Responsibility Principle
- O – Open/Closed Principle
- L – Liskov Substitution Principle
- I – Interface Segregation Principle
- D – Dependency Inversion Principle
SQL & Database Questions
Most fresher roles require at least a basic understanding of databases and SQL. Here are the most commonly asked questions.
17. What is the difference between SQL and NoSQL databases?
SQL databases (MySQL, PostgreSQL) are relational, use structured schemas, and are great for complex queries and transactions. NoSQL databases (MongoDB, Cassandra) are non-relational, schema-flexible, and better suited for large-scale, unstructured data.
18. What are JOIN types in SQL?
- INNER JOIN: Returns rows with matching values in both tables
- LEFT JOIN: Returns all rows from the left table, matched rows from the right
- RIGHT JOIN: Returns all rows from the right table, matched rows from the left
- FULL OUTER JOIN: Returns all rows when there's a match in either table
19. Write a query to find the second highest salary from an Employee table.
SELECT MAX(salary) AS SecondHighestSalary
FROM Employee
WHERE salary < (SELECT MAX(salary) FROM Employee);
This is one of the most frequently asked SQL questions across all companies—from startups to FAANG.
20. Explain normalization and its types.
Normalization is the process of organizing data to minimize redundancy. The main forms are:
- 1NF: Eliminate repeating groups, ensure atomicity
- 2NF: Meet 1NF + remove partial dependencies
- 3NF: Meet 2NF + remove transitive dependencies
- BCNF: A stricter version of 3NF
Problem-Solving & Logic Questions

Beyond textbook knowledge, companies want to see how you think. These questions test your logical reasoning and coding ability simultaneously.
21. FizzBuzz
The classic screening question: Print numbers from 1 to 100, but for multiples of 3 print "Fizz," for multiples of 5 print "Buzz," and for multiples of both print "FizzBuzz."
for i in range(1, 101):
if i % 15 == 0:
print("FizzBuzz")
elif i % 3 == 0:
print("Fizz")
elif i % 5 == 0:
print("Buzz")
else:
print(i)
22. Check if a string is a palindrome.
def is_palindrome(s):
s = s.lower().replace(" ", "")
return s == s[::-1]
print(is_palindrome("racecar")) # Output: True
23. Find the first non-repeating character in a string.
def first_non_repeating(s):
char_count = {}
for char in s:
char_count[char] = char_count.get(char, 0) + 1
for char in s:
if char_count[char] == 1:
return char
return None
print(first_non_repeating("aabcbd")) # Output: 'c'
24. Two Sum Problem
Given an array and a target sum, find two numbers that add up to the target.
def two_sum(nums, target):
seen = {}
for i, num in enumerate(nums):
complement = target - num
if complement in seen:
return [seen[complement], i]
seen[num] = i
return []
print(two_sum([2, 7, 11, 15], 9)) # Output: [0, 1]
This O(n) hash map solution is far superior to the brute-force O(n²) approach. Always mention the time complexity trade-off.
25. Count the number of vowels and consonants in a string.
def count_vowels_consonants(s):
vowels = "aeiouAEIOU"
v_count = c_count = 0
for char in s:
if char.isalpha():
if char in vowels:
v_count += 1
else:
c_count += 1
return v_count, c_count
print(count_vowels_consonants("Hello World")) # Output: (3, 7)
Language Comparison: Which Language Should Freshers Use?
One of the most common questions freshers ask is: "Which programming language should I use for coding interviews?" Here's a comparison to help you decide:
| Language | Pros | Cons | Best For |
|---|---|---|---|
| Python | ✅ Clean syntax ✅ Fast to write ✅ Great for prototyping |
❌ Slower execution ❌ Less common in enterprise |
Startups, DS/ML roles, quick problem solving |
| Java | ✅ Strongly typed ✅ Enterprise standard ✅ Great OOP support |
❌ Verbose ❌ More boilerplate |
Enterprise jobs, Android, large companies |
| C++ | ✅ Fastest execution ✅ Great for competitive programming ✅ STL library |
❌ Complex syntax ❌ Manual memory management |
Competitive programming, system-level roles |
| JavaScript | ✅ Full-stack versatility ✅ Huge job market ✅ Async programming |
❌ Type coercion quirks ❌ Less optimal for DSA |
Web development roles, full-stack positions |
Preparation Tips & Resources for Freshers
Knowing the questions is only half the battle. Here's a structured approach to preparing for coding interview questions for freshers effectively:
Create a Study Plan
Dedicate 4-8 weeks before your interview. Break your preparation into phases:
- Week 1-2: Revise programming fundamentals, OOP, and basic data structures
- Week 3-4: Practice arrays, strings, and searching/sorting problems
- Week 5-6: Move to linked lists, stacks, queues, trees, and graphs
- Week 7-8: Mock interviews, timed practice, and revision
Practice on the Right Platforms
- LeetCode: Filter by "Easy" and focus on the top 100 most-asked questions
- HackerRank: Great for structured learning paths
- GeeksforGeeks: Excellent for theory + practice combined
- InterviewBit: Curated paths specifically for interview prep
Learn to Communicate Your Thought Process
Coding interviews aren't just about getting the right answer—they're about showing how you think. Practice these steps:
- Clarify the problem and ask questions
- Discuss your approach before coding
- Write clean, readable code
- Test with edge cases
- Analyze time and space complexity
🛒 LeetCode premium subscription gift card
View on Amazon →
As an Amazon Associate, we earn from qualifying purchases.
Build Mini-Projects
Having a GitHub portfolio with 2-3 small projects demonstrates practical ability. Even a simple to-do app or calculator shows you can apply concepts beyond theoretical questions.
Common Mistakes Freshers Make in Coding Interviews
After reviewing thousands of fresher interviews, here are the most frequent pitfalls:
- ❌ Jumping straight into code without understanding the problem fully
- ❌ Ignoring edge cases like empty arrays, null values, or negative numbers
- ❌ Memorizing solutions instead of understanding the underlying logic
- ❌ Not practicing on paper or whiteboard—many interviews still use them
- ❌ Neglecting soft skills—communication matters as much as code
- ❌ Panicking when stuck—it's okay to pause, think, and ask for hints
- ❌ Skipping time/space complexity analysis—always discuss Big O notation
And here's what successful candidates do differently:
- ✅ Think aloud and explain their reasoning
- ✅ Start with a brute-force approach then optimize
- ✅ Test their code with sample inputs before declaring it done
- ✅ Stay calm and professional even when they don't know the answer
- ✅ Ask clarifying questions to demonstrate thoroughness
Conclusion
Preparing for coding interview questions for freshers can feel overwhelming, but it becomes manageable when you break it into categories and practice systematically. Here's a quick recap of what we covered:
- Basic programming: String manipulation, recursion, data types, and fundamental concepts
- Data structures & algorithms: Arrays, linked lists, stacks, queues, sorting, and searching
- OOP concepts: The four pillars, SOLID principles, and real-world applications
- SQL & databases: JOINs, normalization, and classic query problems
- Problem-solving: FizzBuzz, Two Sum, palindromes, and pattern recognition
Remember, every senior developer was once a fresher who felt nervous before their first interview. The key is consistent practice, clear communication, and a genuine curiosity about solving problems. Start with the questions in this guide, build up to more complex problems, and don't forget to practice explaining your thought process out loud.
Your first tech job is within reach. Put in the work, stay confident, and you'll ace those coding interview questions for freshers like a pro. Good luck! 🚀