Software Engineer Interview Q&A; (Freshers &
Experienced) + Design Patterns Guide
This PDF contains concise, high-impact sample answers and explanations for common software engineering
interview questions for fresh graduates and experienced candidates. It also includes clear descriptions of
frequently asked design patterns, when to use them, pros/cons, and short pseudocode examples. Rails is
intentionally excluded.
Part I — Fresh Graduates / Junior Engineers: Sample
Questions & Answers
Tell me about yourself.
Keep it short (30-60s). Mention your background, core skills, a couple of projects, and what you want next.
Example: 'I recently graduated in Computer Science. I've built web projects using JavaScript and Python,
completed an internship working on backend APIs, and enjoy solving algorithmic problems. I'm looking for a junior
role where I can apply and expand my skills.'
What is OOP? Name its four principles.
Object-Oriented Programming organizes code using objects. Four main principles: Encapsulation (hide data),
Abstraction (expose essentials), Inheritance (re-use via hierarchy), Polymorphism (same interface, different
behavior).
Explain difference between SQL and NoSQL.
SQL (relational) uses structured schemas and supports complex queries and transactions (e.g., PostgreSQL,
MySQL). NoSQL is schema-less or flexible (e.g., MongoDB, Redis), better for unstructured data and horizontal
scaling. Choose based on data shape, consistency needs, and query patterns.
What is REST API?
REST (Representational State Transfer) is an architectural style for HTTP APIs. Key ideas: stateless requests,
use HTTP verbs (GET, POST, PUT, DELETE), resource-based URLs, and standard status codes.
How do you reverse a string? (explain approach)
Simple approaches: use language built-in reverse method, or two-pointer swap (i from start, j from end swap until
i>=j). For large strings, consider memory and immutability of language.
What is version control and why Git?
Version control tracks changes to code. Git is distributed VCS allowing branching, merging, local commits, and
collaboration via remotes (GitHub/GitLab).
Explain unit testing vs integration testing.
Unit tests check small units (functions/methods) in isolation. Integration tests verify modules work together (e.g.,
service + database). Both are complementary.
Part II — Experienced Engineers: Sample Questions &
Answers
How would you design a scalable web application to handle high traffic?
Start with requirements (RPS, data size, SLAs). Use horizontal scaling for stateless app servers behind a load
balancer. Separate concerns: web layer, application layer, database. Use caching (CDN for static, Redis for
dynamic), database sharding/replicas, asynchronous processing via message queues for heavy tasks, and
microservices if bounded contexts demand independence. Add observability (metrics, logging, tracing) and
auto-scaling.
Explain caching strategies.
Cache-aside (application manages cache), Read-through/Write-through (cache layered with datastore),
TTL-based expiration, and invalidation on updates. Use CDN for static content, Redis/Memcached for low-latency
dynamic caches. Be careful with cache consistency and stale data.
How do you design a scalable API?
Design versioned RESTful endpoints (or GraphQL where fits), keep APIs idempotent where possible, paginate
large responses, use rate-limiting and authentication, validate inputs, and document with OpenAPI. Architect for
horizontal scaling and statelessness so instances can be replicated.
Explain message queues and where to use them.
Message brokers (e.g., RabbitMQ, Kafka) decouple producers and consumers. Use them for background
processing, retries, buffering spikes, streaming data, or event-driven workflows. Choose Kafka for
high-throughput, ordered streams; RabbitMQ for flexible routing and conventional task queues.
What is CI/CD and why is it important?
Continuous Integration (CI) automates testing and merging code frequently. Continuous Deployment/Delivery
(CD) automates releasing to environments. This reduces bugs, shortens feedback loops, and enables rapid, safe
releases.
How would you approach debugging a performance issue in production?
Reproduce or narrow scope, analyze metrics (latency, error rates), use distributed tracing to find slow services,
inspect database slow queries, check resource saturation (CPU, memory, I/O), review recent deployments, and
add targeted logging. Rollback or scale if immediate mitigation needed.
Behavioral: Describe a challenging project and your role.
Use STAR method: Situation, Task, Action, Result. Focus on your contribution, technical decisions, trade-offs,
collaboration, and measurable outcome (e.g., reduced latency by X%, improved reliability).
Part III — Common Design Patterns (Explained)
Below are frequently asked design patterns in interviews. For each: a short definition, use-cases, pros/cons, and a
tiny pseudocode example.
Singleton
Definition: Ensures a class has only one instance and provides a global access point.
Use-cases: configuration manager, logging, connection pool manager.
Pros: controlled access to single resource. Cons: can introduce global state, hard to test (mocking), may hide
dependencies.
Pseudocode:
class Logger:
_instance = null
def getInstance():
if Logger._instance == null:
Logger._instance = new Logger()
return Logger._instance
Factory Method / Factory
Definition: Provides an interface for creating objects but lets subclasses decide which class to instantiate.
Use-cases: object creation where exact types might vary (parsers, UI components per platform).
Pros: decouples creation from usage. Cons: adds extra classes.
Pseudocode:
interface Creator { create(): Product }
class ConcreteCreator implements Creator {
create() => return new ConcreteProduct()
}
Observer
Definition: Defines a subscription mechanism to notify multiple observers about events.
Use-cases: event systems, UI updates (pub/sub), notification systems.
Pros: promotes loose coupling. Cons: can lead to many notifications and ordering issues.
Pseudocode:
subject.subscribe(observer)
subject.notifyAll(event)
Strategy
Definition: Encapsulate interchangeable algorithms and make them interchangeable at runtime.
Use-cases: sorting strategy selection, payment processing (pay by card, pay by wallet).
Pros: promotes open/closed principle and easier testing. Cons: increases number of small classes.
Pseudocode:
context.setStrategy(new QuickSort())
context.execute(data)
Adapter
Definition: Convert interface of a class into another interface expected by clients.
Use-cases: integrating legacy code, third-party libraries.
Pros: allows reuse without modifying existing code. Cons: can add extra layers of indirection.
Pseudocode:
adapter = new LegacyAdapter(legacy)
adapter.callExpectedMethod()
Decorator
Definition: Add responsibilities to objects dynamically without changing their class.
Use-cases: adding logging, caching, or validation to components.
Pros: flexible alternative to subclassing. Cons: many small wrapper objects.
Pseudocode:
component = new ConcreteComponent()
component = new LoggingDecorator(component)
component.operation()
Command
Definition: Encapsulate a request as an object, allowing parameterization and queuing of requests.
Use-cases: undo/redo, task queues, remote API calls.
Pros: decouples sender and receiver, easy to queue and log. Cons: can create many command classes.
Pseudocode:
queue.add(new SaveCommand(document))
queue.executeAll()
MVC (Model-View-Controller)
Definition: Separates application into Model (data), View (UI), and Controller (input logic).
Use-cases: web apps, GUI apps. Pros: separation of concerns, testability. Cons: can be overkill for small apps.
Pseudocode:
controller.handleRequest(req)
model.update()
view.render(model)
Final Tips
• Interview Tips: Practice whiteboard/phone coding, explain your thought process, use examples and trade-offs,
ask clarifying questions, and summarize your final solution.
• Behavioral Answers: Use STAR (Situation, Task, Action, Result) structure. Be honest and focus on learnings.
• Preparation: Solve 2–3 coding problems daily, review system design fundamentals, mock interviews, and read
design pattern use-cases.
Good luck with your interviews!