Software Fundamentals Interview Questions and Answers
100 Software Fundamentals interview questions across 10 topics: Object-Oriented Programming (OOP), SOLID Principles, Design Patterns, Clean Code & Refactoring, Data Structures, Algorithms & Complexity, Concurrency & Multi-threading, System Design & Architecture, Computer Networks & Protocols, and Software Testing & Quality. They cover Junior, Mid-level, and Senior levels, and every question has a short answer to give in the interview, a deeper explanation, common mistakes, and links to official documentation with a last-reviewed date.
Topics
Object-Oriented Programming (OOP)
10 questions
SOLID Principles
9 questions
Design Patterns
11 questions
Clean Code & Refactoring
10 questions
Data Structures
10 questions
Algorithms & Complexity
10 questions
Concurrency & Multi-threading
10 questions
System Design & Architecture
10 questions
Computer Networks & Protocols
10 questions
Software Testing & Quality
10 questions
Object-Oriented Programming (OOP) Interview Questions (Software Fundamentals)
- What are the four pillars of object-oriented programming (OOP), and how do Encapsulation and Abstraction differ?
- Why does the principle "Composition over Inheritance" recommend preferring composition over classical inheritance?
- What is polymorphism, and what is the difference between static dispatch and dynamic dispatch?
- What is the Diamond Problem in multiple inheritance, and how do modern languages solve it?
- What is the precise architectural difference between an abstract class and an interface?
- What is the Law of Demeter (Principle of Least Knowledge), and how does it protect code from long call chains?
- What is the difference between coupling and cohesion, and why do we aim for "high cohesion, low coupling"?
- What is the fundamental difference between a Value Object and an Entity in object-oriented modeling?
- Compare the Anemic Domain Model with the Rich Domain Model.
- What do covariance and contravariance mean for method parameters and return values when overriding a method?
SOLID Principles Interview Questions (Software Fundamentals)
- What is the true meaning of the Single Responsibility Principle (SRP), and how do you identify a "responsibility"?
- How do you apply the Open/Closed Principle without falling into excessive complexity?
- Explain the Liskov Substitution Principle (LSP), preconditions, postconditions, and the famous Rectangle-Square example.
- Why does the Interface Segregation Principle (ISP) warn against fat interfaces?
- What is the essence of the Dependency Inversion Principle (DIP), and how does it differ from Dependency Injection (DI)?
- What is the difference between the Service Locator pattern and dependency injection (IoC) containers, and why is the former sometimes considered an anti-pattern?
- When does applying SOLID become excessive and over-engineered, and what are signs of the Speculative Generality code smell?
- How do you safely start refactoring complex legacy code to follow SOLID without breaking existing behavior?
- What is the difference between true duplication and accidental duplication, and when is duplication better than the wrong abstraction?
Design Patterns Interview Questions (Software Fundamentals)
- What are the object lifetimes in DI containers (Transient, Scoped, Singleton), and what is a captive dependency?
- What are the three main categories of design patterns, and what is the purpose of each?
- What is the fundamental difference between Factory Method and Abstract Factory?
- Why is the Singleton pattern considered an anti-pattern in most modern enterprise applications?
- What is the difference between the Strategy and State patterns, even though their code structures are similar?
- What is the architectural difference between Observer and Publish-Subscribe patterns?
- Compare the similar structural patterns Decorator, Adapter, and Proxy by their purpose.
- When should you use the Builder pattern, and how does it solve the telescoping constructor problem?
- How does the Command pattern enable undo/redo and operation scheduling?
- What shared purpose do the Repository and Unit of Work patterns serve in transaction and database management?
- How does the Chain of Responsibility pattern work, and how is it related to middleware architecture in modern web servers?
Clean Code & Refactoring Interview Questions (Software Fundamentals)
- What are descriptive naming rules and Command-Query Separation (CQS) in clean code?
- What are code smells? Explain the "God Object" and "Feature Envy" smells and how to fix them.
- What is Cyclomatic Complexity, and how do you reduce it to improve testability?
- What is the Boy Scout Rule for managing and reducing technical debt?
- What are best practices for exception handling, Fail-Fast, and avoiding exception swallowing?
- Compare Defensive Programming with Design by Contract (DbC).
- Explain the Extract Method and Replace Conditional with Polymorphism refactoring techniques and when to use them.
- What are effective code review criteria, and how do you distinguish superficial formatting from architectural discussions?
- What is the Primitive Obsession code smell, and how do Value Objects solve it?
- What are KISS and YAGNI, and why are they an important safeguard against project complexity and bloat?
Data Structures Interview Questions (Software Fundamentals)
- Why are arrays faster to iterate over than linked lists even when both have O(N) time complexity?
- How do hash tables work, and what is the difference between collision resolution by chaining and open addressing?
- What are binary search trees (BSTs), and why do we need self-balancing trees such as AVL and Red-Black trees?
- Compare a Queue and a Stack, and what are monotonic stacks?
- How does a binary heap work, and how can a simple array represent it without node pointers, including Heapify?
- What is the difference between an adjacency matrix and an adjacency list for representing graphs?
- How does a Trie (Prefix Tree) work, and why is it better than hash tables for prefix search and autocomplete?
- How do you design an LRU (Least Recently Used) cache with strict O(1) Get and Put operations?
- When should you use a Segment Tree or Fenwick Tree (BIT) for range queries?
- What is the fundamental difference between Stack Memory and Heap Memory for program resource management?
Algorithms & Complexity Interview Questions (Software Fundamentals)
- What is the precise difference between Big-O, Big-Omega, and Big-Theta notation for algorithm analysis?
- Compare QuickSort and MergeSort in terms of space complexity, stability, and worst-case behavior.
- How does binary search work, and what mathematical trick avoids integer overflow?
- Compare Breadth-First Search (BFS) and Depth-First Search (DFS) for graph traversal. When should you choose each?
- When does Dijkstra's algorithm fail to find the shortest path, and why use Bellman-Ford instead?
- How do Two Pointers and Sliding Window transform O(N^2) problems into O(N) solutions?
- What are the key requirements for Dynamic Programming (DP), and how do Memoization and Tabulation differ?
- What is the Greedy Choice Property, and why do greedy algorithms work for Fractional Knapsack but fail for 0/1 Knapsack?
- How does backtracking work, and what is the role of pruning when exploring the state-space tree for N-Queens?
- What are key bit-manipulation tricks, such as checking powers of two, counting set bits, and finding the unique element with XOR?
Concurrency & Multi-threading Interview Questions (Software Fundamentals)
- What is the fundamental difference between processes and threads, and what is the cost of context switching?
- What is a race condition, and what is a critical section in concurrent programming?
- Compare Mutex, Semaphore, Spinlock, and Read-Write Lock. When should you choose each?
- What are Coffman's four conditions for deadlock, and how can you break one to solve the problem?
- What is the memory visibility problem, and what do the volatile keyword and memory barriers do?
- How do Compare-And-Swap (CAS) algorithms and lock-free data structures work?
- How do Thread Pools manage tasks, and what are the ideal sizing formulas for CPU-bound versus I/O-bound work?
- Compare the Thread-per-Request model with the Event Loop using nonblocking I/O.
- How do you design the Producer-Consumer pattern with a bounded buffer and backpressure?
- Compare optimistic and pessimistic concurrency control in databases and memory.
System Design & Architecture Interview Questions (Software Fundamentals)
- What is the difference between horizontal and vertical scaling, and why are stateless servers essential?
- Explain CAP and PACELC theory. What do distributed systems choose during a network partition?
- Compare Cache-Aside, Write-Through, and Write-Back caching strategies. What is a cache stampede?
- How does Consistent Hashing work, and why is it better than the traditional modulo approach for load and cache distribution?
- What is database sharding, and what challenges arise when choosing a shard key and running cross-shard queries?
- Compare relational (SQL) and non-relational (NoSQL) databases in terms of ACID and BASE.
- Compare RabbitMQ's message queue with Apache Kafka's distributed commit log. When should you use each?
- How do the Token Bucket and Leaky Bucket rate-limiting algorithms work?
- How does the Circuit Breaker pattern protect distributed systems from cascading failures?
- How do you manage distributed transactions in a microservices architecture, and how do Two-Phase Commit and Saga differ?
Computer Networks & Protocols Interview Questions (Software Fundamentals)
- Compare the seven-layer OSI model with TCP/IP, and explain how data encapsulation works.
- Compare TCP and UDP. How does the three-way handshake help establish a reliable connection?
- Trace HTTP's evolution from HTTP/1.1 to HTTP/2 multiplexing and HTTP/3 with its UDP-based QUIC engine.
- How do HTTPS and TLS secure communications, and what are the steps of the TLS handshake and key exchange?
- What is the DNS resolution lifecycle, and how do recursive and iterative queries differ?
- Compare real-time communication technologies: WebSockets, Server-Sent Events (SSE), and Long Polling. When should you choose each?
- What are the principles of REST, and what does it mean for an operation to be idempotent?
- What is Cross-Origin Resource Sharing (CORS), and why does a browser automatically send an OPTIONS preflight request?
- How do Man-in-the-Middle (MITM) and SYN Flood attacks work, and how do SYN Cookies help?
- How do Content Delivery Networks (CDNs) work, and how does Anycast Routing direct users to the nearest Edge Server?
Software Testing & Quality Interview Questions (Software Fundamentals)
- What is the Test Pyramid, and what is the ideal balance among unit, integration, and end-to-end (E2E) tests?
- What is the Red-Green-Refactor cycle in Test-Driven Development (TDD), and how does it improve design as well as testing?
- Explain Gerard Meszaros's Test Double types: what is the difference between a Dummy, Stub, Fake, Mock, and Spy?
- What are the five F.I.R.S.T. principles for professional, reliable unit tests?
- Why can code coverage be a misleading metric, and what is mutation testing?
- What are flaky tests, what are their root causes, and how do you eliminate them in CI/CD?
- What is property-based testing, and how does it find unknown edge cases compared with example-based testing?
- What is Behavior-Driven Development (BDD), and how does the Given-When-Then format work?
- What is contract testing, and how does it protect distributed microservices without running a combined E2E environment?
- How do you reduce test execution time in CI pipelines through parallelization and load splitting?