1
What are the four pillars of Object-Oriented Programming?
OOP▼The four pillars of OOP are:
- Encapsulation: Bundling data (attributes) and methods that operate on the data within a single unit (class), restricting direct access to internal state via access modifiers
- Abstraction: Hiding complex implementation details and exposing only the necessary interface. Achieved through abstract classes and interfaces
- Inheritance: Creating new classes (child) that inherit properties and behaviors from existing classes (parent), enabling code reuse
- Polymorphism: Same interface, different implementations. Compile-time (method overloading) and runtime (method overriding) polymorphism
💡 Viva Tip
Always provide real-world examples: "Encapsulation is like a capsule — internal medicine is hidden, only the dose method is exposed."
2
What is the difference between an abstract class and an interface?
OOP▼Abstract Class:
- Can have both abstract (unimplemented) and concrete (implemented) methods
- Can have constructors, instance variables, and static methods
- Supports single inheritance only
- Use when classes share common behavior with some variation
- All methods are abstract by default (Java 8+ allows default/static methods)
- Cannot have constructors or instance variables (only constants)
- Supports multiple inheritance (a class can implement multiple interfaces)
- Use to define a contract/capability that unrelated classes can implement
💡 Viva Tip
Use the "IS-A vs CAN-DO" analogy: Abstract class = "Dog IS-A Animal", Interface = "Dog CAN-DO Swim".
3
Explain SOLID principles with examples.
OOP▼- S — Single Responsibility: A class should have only one reason to change. E.g., separate
UserAuthandUserProfileclasses instead of one monolithicUserclass - O — Open/Closed: Open for extension, closed for modification. Use inheritance/interfaces to add new behavior without changing existing code
- L — Liskov Substitution: Child classes should be substitutable for parent classes without breaking the program. If
Birdhasfly(),Penguin extends Birdviolates this - I — Interface Segregation: Many specific interfaces are better than one general-purpose interface. Don't force classes to implement methods they don't need
- D — Dependency Inversion: Depend on abstractions, not concrete implementations. Use dependency injection to decouple modules
💡 Viva Tip
SOLID is a favorite interview topic. Prepare one concrete code example for each principle from your projects.
4
What is the difference between Array, LinkedList, and ArrayList?
DSA▼Array: Fixed size, contiguous memory, O(1) access by index, O(n) insertion/deletion. Stores primitives or objects.
LinkedList: Dynamic size, non-contiguous memory (nodes with pointers), O(n) access, O(1) insertion/deletion at known position. Better for frequent insertions.
ArrayList: Dynamic array (resizable), contiguous memory, O(1) amortized access, O(n) insertion in middle. Internally uses array with automatic resizing (typically 1.5x or 2x growth).
When to use: Array for fixed-size, performance-critical data. ArrayList for dynamic lists with frequent reads. LinkedList for frequent insertions/deletions at arbitrary positions.
LinkedList: Dynamic size, non-contiguous memory (nodes with pointers), O(n) access, O(1) insertion/deletion at known position. Better for frequent insertions.
ArrayList: Dynamic array (resizable), contiguous memory, O(1) amortized access, O(n) insertion in middle. Internally uses array with automatic resizing (typically 1.5x or 2x growth).
When to use: Array for fixed-size, performance-critical data. ArrayList for dynamic lists with frequent reads. LinkedList for frequent insertions/deletions at arbitrary positions.
💡 Viva Tip
Mention time complexity for each operation — interviewers value Big-O fluency.
5
Explain the difference between Stack and Queue. Where are they used?
DSA▼Stack (LIFO — Last In First Out):
- Operations: push (add to top), pop (remove from top), peek (view top)
- Use cases: Undo/redo functionality, browser back button, function call stack, expression evaluation, DFS traversal
- Operations: enqueue (add to rear), dequeue (remove from front), peek
- Use cases: Task scheduling, print queue, BFS traversal, message queues (RabbitMQ, Kafka), request handling in web servers
💡 Viva Tip
Relate to real systems: "Our API rate limiter uses a queue-based sliding window approach."
6
What is the time complexity of common sorting algorithms?
DSA▼- Bubble Sort: O(n²) average/worst, O(n) best (already sorted), stable, in-place
- Selection Sort: O(n²) all cases, not stable, in-place
- Insertion Sort: O(n²) average/worst, O(n) best, stable, in-place — good for nearly sorted data
- Merge Sort: O(n log n) all cases, stable, O(n) extra space — divide and conquer
- Quick Sort: O(n log n) average, O(n²) worst, not stable, in-place — fastest in practice
- Heap Sort: O(n log n) all cases, not stable, in-place
💡 Viva Tip
Know when to use which: Quick Sort for general purpose, Merge Sort when stability matters, Counting/Radix Sort for integers in known range.
7
What is normalization? Explain 1NF, 2NF, and 3NF.
Database▼Normalization is the process of organizing database tables to minimize redundancy and dependency.
- 1NF (First Normal Form): Each column contains atomic (indivisible) values. No repeating groups. Each row is unique (has a primary key)
- 2NF (Second Normal Form): Must be in 1NF + no partial dependency. Every non-key column must depend on the entire primary key (relevant when using composite keys)
- 3NF (Third Normal Form): Must be in 2NF + no transitive dependency. Non-key columns must depend only on the primary key, not on other non-key columns
💡 Viva Tip
Also know about denormalization — sometimes we intentionally add redundancy for query performance (common in data warehousing).
8
What is the difference between SQL and NoSQL databases?
Database▼SQL (Relational): Structured tables with rows/columns, fixed schema, ACID compliant, uses SQL queries. Examples: MySQL, PostgreSQL, Oracle, SQL Server.
NoSQL (Non-Relational): Flexible schema, various data models, horizontal scaling. Types:
NoSQL (Non-Relational): Flexible schema, various data models, horizontal scaling. Types:
- Document: MongoDB, CouchDB — JSON-like documents
- Key-Value: Redis, DynamoDB — simple key-value pairs
- Column-Family: Cassandra, HBase — columns grouped by family
- Graph: Neo4j — nodes and relationships
💡 Viva Tip
Don't say "NoSQL is better" — explain trade-offs. Mention CAP theorem: Consistency, Availability, Partition tolerance — you can only guarantee two.
9
What is REST API? Explain its principles.
Web Dev▼REST (Representational State Transfer) is an architectural style for designing networked applications. A RESTful API uses HTTP methods to perform CRUD operations on resources.
Key Principles:
Key Principles:
- Client-Server: Separation of concerns — client handles UI, server handles data
- Stateless: Each request contains all information needed; server doesn't store session state
- Uniform Interface: Standard HTTP methods — GET (read), POST (create), PUT (update), DELETE (remove), PATCH (partial update)
- Resource-Based: Everything is a resource identified by URIs (e.g.,
/api/users/123) - Cacheable: Responses can be cached to improve performance
- Layered System: Client doesn't know if it's talking to the server directly or through intermediaries
💡 Viva Tip
Be ready to discuss HTTP status codes: 200 (OK), 201 (Created), 400 (Bad Request), 401 (Unauthorized), 404 (Not Found), 500 (Server Error).
10
What is the difference between session-based and token-based authentication?
Web Dev▼Session-Based:
- Server creates a session and stores it (in memory/database)
- Session ID sent to client via cookie
- Client sends cookie with every request
- Server looks up session to verify user
- Stateful — server must maintain session store
- Server generates a signed token (JWT) after authentication
- Token contains user info (payload) + signature
- Client stores token (localStorage/cookie) and sends in Authorization header
- Server verifies token signature — no server-side storage needed
- Stateless — scales better for distributed systems
💡 Viva Tip
Mention security: JWT should use short expiration + refresh tokens. Never store sensitive data in JWT payload (it's only Base64 encoded, not encrypted).
11
What is the difference between monolithic and microservices architecture?
System Design▼Monolithic: Single deployable unit containing all business logic. Shared database, single codebase. Simple to develop initially but becomes hard to scale and maintain as it grows.
Microservices: Application broken into small, independent services. Each service has its own database, can be deployed independently, communicates via APIs (REST/gRPC/message queue).
Comparison:
Microservices: Application broken into small, independent services. Each service has its own database, can be deployed independently, communicates via APIs (REST/gRPC/message queue).
Comparison:
- Scaling: Monolith — scale entire app; Microservices — scale only the service that needs it
- Deployment: Monolith — deploy everything; Microservices — deploy individually
- Technology: Monolith — single stack; Microservices — each service can use different tech
- Complexity: Monolith — simpler; Microservices — requires orchestration, service discovery, distributed tracing
💡 Viva Tip
Don't blindly advocate microservices. "Start monolith, extract microservices when needed" is a mature answer that shows practical experience.
12
How would you design a URL shortener like bit.ly?
System Design▼Requirements: Given a long URL, generate a short unique URL. Redirect short URL to original. Handle millions of requests.
Core Design:
Core Design:
- Encoding: Generate a unique 6-7 character code using Base62 (a-z, A-Z, 0-9). 62⁷ = ~3.5 trillion unique URLs
- ID Generation: Auto-incrementing counter (converted to Base62) or hash-based (MD5/SHA256 → take first 7 chars)
- Database: Store mapping (short_code → long_url, created_at, expiry). NoSQL (DynamoDB) or SQL with indexing
- Caching: Redis/Memcached for hot URLs — most URLs follow Pareto distribution (20% URLs get 80% traffic)
- Redirect: HTTP 301 (permanent) or 302 (temporary) redirect
💡 Viva Tip
Discuss trade-offs: hash collision handling, custom aliases, analytics tracking, rate limiting, and URL expiration.
13
What is Git? Explain branching strategies.
General▼Git is a distributed version control system that tracks changes in source code during development.
Common Branching Strategies:
Common Branching Strategies:
- Git Flow: main, develop, feature/*, release/*, hotfix/* branches. Best for scheduled releases
- GitHub Flow: Simple — main branch + feature branches. PR-based workflow, continuous deployment
- Trunk-Based: All developers commit to main/trunk frequently. Feature flags for incomplete features. Best for CI/CD
git branch, git checkout -b, git merge, git rebase, git stash, git cherry-pick💡 Viva Tip
Know the difference between merge and rebase. Merge preserves history, rebase creates a linear history. Never rebase shared/public branches.
14
What is CI/CD? How does it improve development?
General▼CI (Continuous Integration): Developers frequently merge code changes into a shared repository. Each merge triggers automated builds and tests to detect issues early.
CD (Continuous Delivery/Deployment):
Benefits: Faster feedback loops, fewer integration bugs, reliable releases, reduced manual work, consistent environments.
CD (Continuous Delivery/Deployment):
- Continuous Delivery: Code is always in a deployable state. Deployment to production requires manual approval
- Continuous Deployment: Every change that passes all tests is automatically deployed to production
Benefits: Faster feedback loops, fewer integration bugs, reliable releases, reduced manual work, consistent environments.
💡 Viva Tip
Mention your experience: "In my last project, we used GitHub Actions for CI — running unit tests, linting, and building Docker images on every PR."
15
Tell me about a challenging technical problem you solved.
General▼Use the STAR method to structure your answer:
- Situation: Set the context — project, team, constraints
- Task: What specific problem needed solving?
- Action: What steps did you take? What technologies/approaches did you use?
- Result: What was the outcome? Quantify if possible (performance improved by X%, reduced load time from 5s to 1s)
💡 Viva Tip
Prepare 2-3 STAR stories from your experience. Focus on problems involving debugging, optimization, or architecture decisions.