Computer Science is a vast and dynamic field, but its core principles remain constant. Whether you’re a student, a job seeker, or a seasoned professional looking to refresh your memory, mastering these fundamental concepts is crucial. This comprehensive guide covers 100 of the most common Computer Science questions across key domains like Data Structures & Algorithms, Object-Oriented Programming, Operating Systems, Databases, Computer Networks, and more. Each question comes with a concise answer and a practical example to solidify your understanding.
Let’s dive in!
Section 1: Data Structures and Algorithms (DSA) – Questions 1-30
DSA is the backbone of efficient programming. Expect a significant portion of interviews and fundamental CS knowledge to revolve around these concepts.
Core Concepts & Complexity
- What is an algorithm?
- Answer: A definite, step-by-step procedure or set of rules used to solve a specific problem or perform a computation.
- Example: Sorting algorithms (e.g., Merge Sort, Quick Sort) arrange elements in a specific order.
- What is Big O notation?
- Answer: A mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity. In CS, it’s used to classify algorithms by how their run-time or space requirements grow as the input size increases.
- Example: An algorithm accessing an array element by index has O(1) (constant time) complexity.
- What is the difference between time complexity and space complexity?
- Answer: Time complexity measures the amount of time an algorithm takes to run as a function of the input size. Space complexity measures the amount of memory an algorithm uses as a function of the input size.
- Example: A recursive factorial function has O(N) time complexity and O(N) space complexity (due to call stack).
- Explain O(1), O(logN), O(N), O(NlogN), O(N2), O(2N), O(N!) complexities.
- Answer:
- O(1): Constant time (e.g., array element access).
- O(logN): Logarithmic time (e.g., binary search).
- O(N): Linear time (e.g., iterating through a list).
- O(NlogN): “Linearithmic” time (e.g., Merge Sort, Quick Sort).
- O(N2): Quadratic time (e.g., nested loops, bubble sort).
- O(2N): Exponential time (e.g., recursive Fibonacci without memoization).
- O(N!): Factorial time (e.g., brute-force traveling salesman).
- Example: Calculating Nth Fibonacci number recursively is O(2N).
- Answer:
Arrays & Linked Lists
- Difference between Array and Linked List?
- Answer: An Array is a collection of elements of the same type stored in contiguous memory locations; its size is usually fixed. A Linked List is a sequence of nodes, where each node stores data and a reference (or pointer) to the next node; its size is dynamic.
- Example: arr = [10, 20, 30] (Array) vs. 10 -> 20 -> 30 (Linked List).
- What is a Doubly Linked List?
- Answer: A linked list where each node has pointers to both the next and the previous node.
- Example: Facilitates traversal in both forward and backward directions.
- What is a Circular Linked List?
- Answer: A linked list where the last node points back to the first node, forming a circle.
- Example: Useful for implementing a queue that processes items in a round-robin fashion.
- When would you use an Array vs. a Linked List?
- Answer: Use Arrays for constant-time access by index, or when size is fixed/known. Use Linked Lists for frequent insertions/deletions at arbitrary positions, or when size is unknown and memory can be non-contiguous.
Stacks & Queues
- What is a Stack?
- Answer: A Last-In, First-Out (LIFO) data structure. Elements are added (pushed) and removed (popped) from the same end (the “top”).
- Example: Browser history (back button), function call stack.
- What is a Queue?
- Answer: A First-In, First-Out (FIFO) data structure. Elements are added (enqueued) at one end (the “rear”) and removed (dequeued) from the other end (the “front”).
- Example: Printer spooler, task scheduling.
- How can you implement a Queue using two Stacks?
- Answer: Use one stack for enqueuing and another for dequeuing. When dequeuing, if the dequeue stack is empty, pop all elements from the enqueue stack and push them onto the dequeue stack, then pop from the dequeue stack.
Trees
- What is a Tree data structure?
- Answer: A non-linear, hierarchical data structure consisting of nodes connected by edges, with a single root node and no cycles.
- Example: File system directories.
- What is a Binary Tree?
- Answer: A tree data structure where each node has at most two children, referred to as the left child and the right child.
- What is a Binary Search Tree (BST)?
- Answer: A binary tree where the left child of a node contains values less than the node’s value, and the right child contains values greater than the node’s value.
- Example: Efficient for searching, insertion, and deletion (O(logN) average).
- What is a balanced binary tree? Why is it important?
- Answer: A binary tree where the height difference between the left and right subtrees of any node is at most one. It’s important because it ensures O(logN) time complexity for operations by preventing degeneration into a linked list (O(N)).
- Example: AVL trees, Red-Black trees are self-balancing BSTs.
- What is a Heap? (Min-Heap vs. Max-Heap)
- Answer: A complete binary tree that satisfies the heap property: for a Min-Heap, every node’s value is less than or equal to its children’s values; for a Max-Heap, every node’s value is greater than or equal to its children’s values.
- Example: Priority Queues are often implemented using heaps.
- What is a Trie (Prefix Tree)?
- Answer: A tree-like data structure used to store a dynamic set or associative array where keys are usually strings. It allows for fast retrieval of keys based on their prefixes.
- Example: Autocomplete features, spell checkers.
Graphs
- What is a Graph data structure?
- Answer: A non-linear data structure consisting of a finite set of vertices (nodes) and a set of edges connecting these vertices.
- Example: Social networks (people are vertices, friendships are edges), road maps.
- Difference between BFS (Breadth-First Search) and DFS (Depth-First Search)?
- Answer: BFS explores all neighbors at the current depth level before moving to the next level (uses a Queue). DFS explores as far as possible along each branch before backtracking (uses a Stack or recursion).
- Example: BFS finds the shortest path in an unweighted graph. DFS is good for topological sorting or finding cycles.
- What is a Weighted Graph?
- Answer: A graph where each edge has a numerical value (weight) associated with it, representing cost, distance, time, etc.
- Example: Road map with distances between cities as weights.
- What is Dijkstra’s algorithm?
- Answer: An algorithm for finding the shortest paths between nodes in a weighted graph, where all edge weights are non-negative.
- Example: Used in GPS systems to find the shortest route.
- What is an adjacency matrix vs. an adjacency list for graph representation?
- Answer: Adjacency Matrix: A 2D array where matrix[i][j] is 1 if there’s an edge between vertex i and j, else 0. Adjacency List: An array of lists/vectors where list[i] contains all vertices adjacent to vertex i.
- Example: Adjacency list is generally preferred for sparse graphs (few edges), adjacency matrix for dense graphs (many edges).
Hashing
- How does a Hash Table (or HashMap) work?
- Answer: It stores data in an array structure, using a hash function to compute an index (a “bucket” or “slot”) into the array where the value is to be stored. It provides average O(1) time complexity for insertion, deletion, and retrieval.
- Example: Storing {“apple”: 1, “banana”: 2}. “apple” is hashed to an index, and 1 is stored there.
- What is a hash collision? How is it handled?
- Answer: A hash collision occurs when two different keys hash to the same index in the hash table. It’s handled by methods like chaining (using a linked list at each index) or open addressing (probing for the next available slot).
Sorting & Searching
- What is Binary Search? What are its prerequisites?
- Answer: An efficient search algorithm that finds the position of a target value within a sorted array. It repeatedly divides the search interval in half.
- Prerequisites: The array must be sorted.
- Explain Merge Sort.
- Answer: A divide-and-conquer sorting algorithm that divides an unsorted list into N sublists, each containing one element, then repeatedly merges sublists to produce new sorted sublists until there is only one sorted list remaining.
- Time Complexity: O(NlogN).
- Explain Quick Sort.
- Answer: A divide-and-conquer sorting algorithm that picks an element as a pivot and partitions the array around the picked pivot.
- Time Complexity: Average O(NlogN), worst-case O(N2).
- Explain Bubble Sort.
- Answer: A simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order.
- Time Complexity: O(N2). (Generally inefficient for large datasets).
- What is a “stable” sorting algorithm?
- Answer: A sorting algorithm is stable if it preserves the relative order of elements with equal values.
- Example: Merge Sort is stable; Quick Sort is generally not.
- What is Dynamic Programming?
- Answer: An optimization technique that solves complex problems by breaking them down into simpler subproblems and storing the results of these subproblems to avoid redundant calculations. It’s used when problems have optimal substructure and overlapping subproblems.
- Example: Calculating Fibonacci sequence efficiently using memoization (top-down) or tabulation (bottom-up).
Section 2: Object-Oriented Programming (OOP) – Questions 31-45
OOP is a paradigm that structures programs into objects, which are instances of classes. Understanding its principles is fundamental for modern software development.
- What are the four main pillars of OOP?
- Answer:
- Abstraction: Hiding complex implementation details, showing only essentials.
- Encapsulation: Bundling data and methods into a single unit (class).
- Inheritance: Creating new classes from existing ones, reusing code.
- Polymorphism: Objects taking on many forms, allowing a single interface for different types.
- Example: A car’s driver uses a steering wheel (abstraction), but doesn’t need to know engine mechanics.
- Answer:
- What is a Class?
- Answer: A blueprint or a template for creating objects. It defines the structure (attributes/fields) and behavior (methods) that its objects will have.
- Example: A Car class defines attributes like color, make, model and methods like start(), stop().
- What is an Object?
- Answer: An instance of a class. It is a real-world entity with state (attributes) and behavior (methods).
- Example: myCar = new Car(“red”, “Toyota”, “Camry”) is an object.
- What is Abstraction?
- Answer: The process of hiding the internal implementation details and showing only the necessary functionalities to the outside world.
- Example: Using a remote control to change TV channels without knowing the internal circuitry.
- What is Encapsulation?
- Answer: The binding of data (attributes) and methods (functions) that operate on the data into a single unit (a class), and restricting direct access to some of the object’s components (data hiding).
- Example: A BankAccount class where balance is private and can only be modified via public deposit() or withdraw() methods.
- What is Inheritance?
- Answer: A mechanism where a new class (subclass/child) is derived from an existing class (superclass/parent), inheriting its attributes and methods. It promotes code reusability.
- Example: A SportsCar class inheriting from a Car class.
- What is Polymorphism?
- Answer: The ability of an object to take on many forms. It allows a single interface to represent different underlying forms (e.g., method overloading or overriding).
- Example: A Shape class with a draw() method, and Circle and Square subclasses overriding draw() to draw their specific shapes.
- Difference between Method Overloading and Overriding?
- Answer: Overloading (Compile-time/Static Polymorphism): Multiple methods in the same class have the same name but different parameters. Overriding (Run-time/Dynamic Polymorphism): A method in the subclass has the same name, same parameters, and same return type as a method in its superclass, providing a specific implementation.
- What is an Interface?
- Answer: A blueprint of a class that defines a set of methods that a class must implement. It specifies what a class must do, but not how.
- Example: A Flyable interface with a fly() method, implemented by Bird and Airplane classes.
- What is an Abstract Class?
- Answer: A class that cannot be instantiated directly and may contain abstract (unimplemented) methods, along with concrete (implemented) methods. Subclasses must implement the abstract methods.
- Example: An AbstractShape class with an abstract calculateArea() method and a concrete getColor() method.
- Difference between an Abstract Class and an Interface?
- Answer:
- Abstract Class: Can have abstract and concrete methods, can have constructors, can define instance variables, a class can extend only one abstract class.
- Interface: Can only have abstract methods (in older Java, now can have default/static methods), cannot have constructors, cannot define instance variables (only constants), a class can implement multiple interfaces.
- Answer:
- What is Composition (vs. Inheritance)?
- Answer: Composition is a “has-a” relationship where one class contains another class as an instance variable. It’s often preferred over inheritance for better flexibility and less tight coupling.
- Example: A Car “has an” Engine (Composition) vs. a SportsCar “is a” Car (Inheritance).
- What is Association, Aggregation, and Composition?
- Answer: These describe relationships between objects:
- Association: A general “uses” or “relates to” relationship.
- Aggregation: A “has-a” relationship where the child can exist independently of the parent (e.g., “Department has Students”).
- Composition: A “part-of” relationship where the child cannot exist independently of the parent (e.g., “House has Rooms”).
- Answer: These describe relationships between objects:
- What are access modifiers?
- Answer: Keywords in OOP languages (like Java’s public, private, protected, default) that set the accessibility level for classes, fields, methods, and constructors.
- Example: A private field can only be accessed within its own class.
- What is a constructor?
- Answer: A special method used to initialize an object when it is created. It has the same name as the class and no return type.
- Example: public Car(String make, String model) { this.make = make; this.model = model; }
Section 3: Operating Systems (OS) – Questions 46-60
The OS is the core software managing all computer resources. A good understanding of its functions is vital.
- What is an Operating System (OS)?
- Answer: Software that manages computer hardware and software resources, providing common services for computer programs. It acts as an interface between the user and the computer hardware.
- Example: Windows, macOS, Linux.
- What is a Process?
- Answer: An independent instance of a running program with its own memory space, resources, and code.
- Example: Opening a web browser creates a process.
- What is a Thread?
- Answer: A smaller unit of execution within a process that shares the process’s memory space and resources. Threads allow a process to perform multiple tasks concurrently.
- Example: A web browser tab or a spell-checking function within a word processor might run as a thread.
- Difference between a Process and a Thread?
- Answer: Processes are independent with their own memory and resources, requiring more overhead for creation and context switching. Threads share the parent process’s memory and resources, making them lighter-weight for concurrency within a single program.
- What is Multithreading?
- Answer: The ability of a CPU to execute multiple threads concurrently, either by switching between them rapidly (on a single core) or by running them simultaneously (on multiple cores).
- Example: A video game using one thread for rendering and another for AI.
- What is a Deadlock? How to prevent/avoid it?
- Answer: A situation where two or more processes are blocked indefinitely, waiting for each other to release resources.
- Conditions for Deadlock (Coffman conditions): Mutual Exclusion, Hold and Wait, No Preemption, Circular Wait.
- Prevention/Avoidance: Break one of the four conditions. Banker’s Algorithm for avoidance.
- What is a Semaphore?
- Answer: A synchronization primitive (a variable or abstract data type) used to control access to a common resource by multiple processes or threads in a concurrent system, preventing race conditions.
- Example: Limiting the number of concurrent database connections.
- What is a Mutex?
- Answer: A binary semaphore (lock) used to provide exclusive access to a shared resource for a single thread at a time.
- Example: Ensuring only one thread writes to a critical section of code at a time.
- Difference between Mutex and Semaphore?
- Answer: Mutex is for exclusive access to a single resource (binary semaphore, owner-specific). Semaphore is for signaling between processes and controlling access to a pool of resources (can be counting, not owner-specific).
- What is Paging?
- Answer: A memory management scheme that allows the operating system to retrieve processes from secondary storage into main memory in the form of equally sized blocks called “pages.”
- Example: Allows processes to run even if their entire code doesn’t fit into physical memory.
- What is Virtual Memory?
- Answer: A memory management capability of an OS that uses hardware and software to allow a computer to compensate for physical memory shortages by temporarily transferring data from RAM to disk storage.
- Example: Running multiple large applications that collectively exceed the physical RAM capacity.
- What is a Context Switch?
- Answer: The process of storing the state (context) of a process or thread so that it can be restored and execution can be resumed from the same point later, and then loading the state of another process or thread.
- Example: When the OS switches from running one program to another.
- Explain CPU Scheduling algorithms (e.g., FCFS, SJF, Round Robin).
- Answer: Methods used by the OS to decide which process in the ready queue is to be executed next.
- FCFS (First-Come, First-Served): Processes are executed in the order they arrive.
- SJF (Shortest Job First): The process with the smallest execution time is picked next.
- Round Robin: Each process is given a small unit of CPU time (time quantum) in a circular fashion.
- Example: Round Robin is widely used in modern OS for fair CPU allocation.
- Answer: Methods used by the OS to decide which process in the ready queue is to be executed next.
- What is a System Call?
- Answer: The programmatic way in which a computer program requests a service from the kernel of the operating system it is executed on.
- Example: read(), write(), fork(), exit().
- What is caching?
- Answer: A technique where frequently accessed data is stored in a faster storage medium (cache) closer to the processor, to reduce retrieval time.
- Example: CPU cache, web browser cache.
Section 4: Database Management Systems (DBMS) – Questions 61-75
Databases are crucial for storing and managing information. Understanding how they work and how to interact with them is essential.
- What is a DBMS?
- Answer: A Database Management System (DBMS) is software that allows users to define, create, maintain, and control access to a database.
- Example: MySQL, PostgreSQL, Oracle, MongoDB.
- What is the difference between SQL and NoSQL databases?
- Answer:
- SQL (Relational): Uses structured query language, predefined schema, ACID properties, good for complex queries and structured data.
- NoSQL (Non-Relational): Flexible schema, scalable horizontally, often BASE properties, good for unstructured/semi-structured data, high velocity data.
- Example: SQL: PostgreSQL; NoSQL: MongoDB (document-based), Cassandra (column-family).
- Answer:
- What are ACID properties in DBMS?
- Answer: Properties of database transactions that guarantee data validity:
- Atomicity: All or nothing.
- Consistency: Transaction brings database from one valid state to another.
- Isolation: Concurrent transactions execute independently.
- Durability: Once committed, changes persist.
- Example: A bank transfer must be ACID-compliant: either both debit and credit happen, or neither.
- Answer: Properties of database transactions that guarantee data validity:
- What is a Primary Key?
- Answer: A column (or set of columns) in a table that uniquely identifies each row in that table. It cannot contain NULL values and must be unique.
- Example: StudentID in a Students table.
- What is a Foreign Key?
- Answer: A column (or set of columns) in one table that refers to the Primary Key in another table, establishing a link between them.
- Example: StudentID in a CoursesTaken table referring to StudentID in the Students table.
- What is Database Normalization?
- Answer: A process of organizing the columns and tables of a relational database to minimize data redundancy and improve data integrity. It involves a series of forms (1NF, 2NF, 3NF, BCNF, etc.).
- Example: Breaking down a table with redundant customer addresses into separate Customers and Addresses tables.
- Explain 1NF, 2NF, and 3NF.
- Answer:
- 1NF (First Normal Form): Each column contains atomic (single) values, and there are no repeating groups of columns.
- 2NF (Second Normal Form): Is in 1NF and all non-key attributes are fully functionally dependent on the primary key (no partial dependencies).
- 3NF (Third Normal Form): Is in 2NF and has no transitive dependencies (non-key attributes are not dependent on other non-key attributes).
- Answer:
- What is an Index in a database?
- Answer: A data structure that improves the speed of data retrieval operations on a database table at the cost of additional writes and storage space.
- Example: An index on a LastName column helps find records by last name much faster.
- What is a Join in SQL? (Inner, Left, Right, Full)
- Answer: Used to combine rows from two or more tables based on a related column between them.
- INNER JOIN: Returns only rows with matching values in both tables.
- LEFT (OUTER) JOIN: Returns all rows from the left table, and matching rows from the right table.
- RIGHT (OUTER) JOIN: Returns all rows from the right table, and matching rows from the left table.
- FULL (OUTER) JOIN: Returns all rows when there is a match in one of the tables.
- Example: SELECT * FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;
- Answer: Used to combine rows from two or more tables based on a related column between them.
- What is a View in SQL?
- Answer: A virtual table based on the result-set of an SQL query. A view contains rows and columns, just like a real table, but it does not store data itself; it displays data stored in other tables.
- Example: Creating a view ActiveUsers that only shows users with status = ‘active’.
- What is a Stored Procedure?
- Answer: A pre-compiled collection of one or more SQL statements or commands stored in the database. They can accept parameters, return values, and improve performance and security.
- Example: A stored procedure GetOrderDetails(OrderID) that returns all items for a given order ID.
- What is a Transaction in DBMS?
- Answer: A single logical unit of work that accesses and potentially modifies the contents of a database. It’s treated as an indivisible unit (ACID properties).
- Example: Transferring money between two bank accounts involves a single transaction.
- What is a Trigger?
- Answer: A special type of stored procedure that automatically executes when a specified event occurs in the database server.
- Example: A trigger that automatically updates an inventory_count whenever an order_items table is updated.
- What is Denormalization? When is it used?
- Answer: The process of intentionally adding redundancy to a database, often by combining tables or adding duplicate data, to improve read performance for specific queries.
- When used: In data warehousing or read-heavy applications where query speed is paramount and data integrity can be managed.
- What is the CAP Theorem?
- Answer: A fundamental theorem in distributed computing stating that it is impossible for a distributed data store to simultaneously provide more than two out of the following three guarantees: Consistency, Availability, and Partition tolerance.
- Example: If network partitions occur, you must choose between consistency (data is always up-to-date across all nodes) and availability (every request receives a response).
Section 5: Computer Networks – Questions 76-90
Computer networks enable communication between devices. Understanding network protocols and layers is essential.
- What are the layers of the OSI Model?
- Answer: A conceptual framework for understanding network communication, divided into seven layers: Physical, Data Link, Network, Transport, Session, Presentation, Application.
- Example: Application Layer: HTTP, FTP, SMTP; Transport Layer: TCP, UDP.
- What are the layers of the TCP/IP Model?
- Answer: A more practical model, widely used in the Internet, with four or five layers: Network Access (or Link), Internet, Transport, Application.
- Example: Maps closely to OSI, but combines some layers.
- Difference between TCP and UDP?
- Answer:
- TCP (Transmission Control Protocol): Connection-oriented, reliable, ordered delivery, error-checked, flow control, congestion control. Slower.
- UDP (User Datagram Protocol): Connectionless, unreliable, unordered delivery, no error checking, no flow/congestion control. Faster.
- Example: TCP for web browsing (HTTP), email (SMTP); UDP for video streaming, online gaming (where speed is critical, and some packet loss is acceptable).
- Answer:
- What is an IP address? (IPv4 vs. IPv6)
- Answer: A numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication.
- IPv4: 32-bit address (e.g., 192.168.1.1).
- IPv6: 128-bit address, designed to address the exhaustion of IPv4 addresses.
- Example: Your home router has a public IP address.
- Answer: A numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication.
- What is a MAC address?
- Answer: A Media Access Control (MAC) address is a unique identifier assigned to a network interface controller (NIC) for communications within a network segment. It operates at the Data Link layer.
- Example: 00:1A:2B:3C:4D:5E (unique to your network card).
- Difference between Hub, Switch, and Router?
- Answer:
- Hub: Connects multiple devices in a network; broadcasts all incoming data to all ports (Physical layer).
- Switch: Connects multiple devices; learns MAC addresses and forwards data only to the intended recipient (Data Link layer).
- Router: Connects different networks; forwards data packets between networks using IP addresses (Network layer).
- Example: Your home WiFi device is typically a router with a built-in switch and wireless access point.
- Answer:
- What is DNS (Domain Name System)?
- Answer: A hierarchical and decentralized naming system for computers, services, or any resource connected to the Internet or a private network. It translates human-readable domain names into numerical IP addresses.
- Example: Translates www.google.com to 142.250.72.106.
- What happens when you type a URL in your browser and press Enter?
- Answer: A multi-step process:
- DNS Resolution: Browser asks DNS for the website’s IP address.
- TCP Connection: Browser establishes a TCP connection with the server at that IP.
- HTTP Request: Browser sends an HTTP GET request for the page.
- HTTP Response: Server sends the HTTP response (HTML, CSS, JS, etc.).
- Browser Rendering: Browser renders the webpage.
- What is HTTP? What is HTTPS?
- Answer:
- HTTP (Hypertext Transfer Protocol): The protocol used for transmitting web pages over the Internet. It is stateless.
- HTTPS (Hypertext Transfer Protocol Secure): The secure version of HTTP, which uses SSL/TLS encryption to protect data transmitted between the browser and the server.
- Example: Always use HTTPS for sensitive data like logins or financial transactions.
- What is a Firewall?
- Answer: A network security system that monitors and controls incoming and outgoing network traffic based on predetermined security rules.
- Example: Blocks unauthorized access to your computer or network.
- What is latency vs. bandwidth?
- Answer:
- Bandwidth: The maximum rate of data transfer across a given path (bits per second).
- Latency: The time delay from when a data packet is sent until it is received.
- Example: A wider highway (bandwidth) allows more cars, but a speed limit or traffic jam (latency) can still make the journey slow.
- Answer:
- What is a Subnet Mask?
- Answer: A 32-bit number that divides an IP address into network and host addresses. It helps a router determine which part of an IP address refers to the network and which part refers to the host within that network.
- Example: 255.255.255.0 for a common home network.
- What is ARP (Address Resolution Protocol)?
- Answer: A protocol used by the Internet Protocol (IP) to map IP network addresses to the hardware (MAC) addresses used by a data link protocol.
- Example: When your computer wants to send data to another device on the local network, but only knows its IP, ARP finds its MAC address.
- What is NAT (Network Address Translation)?
- Answer: A method of remapping an IP address space into another by modifying network address information in the IP header of packets while they are in transit across a traffic routing device. It allows multiple devices on a private network to share a single public IP address.
- Example: Your home router uses NAT to allow all your devices to share one public IP provided by your ISP.
- What is a Proxy Server?
- Answer: A server that acts as an intermediary for requests from clients seeking resources from other servers. It can improve performance (caching), security, and privacy.
- Example: A corporate proxy server that filters web content or caches frequently accessed pages.
Section 6: Software Engineering & System Design – Questions 91-100
These questions often combine knowledge from various CS areas and focus on practical application and design thinking.
- What is Software Development Life Cycle (SDLC)?
- Answer: A framework defining the phases involved in developing, deploying, and maintaining an information system. Common models include Waterfall, Agile, Scrum, DevOps.
- Example: Requirements -> Design -> Implementation -> Testing -> Deployment -> Maintenance.
- Difference between Monolithic and Microservices architecture?
- Answer:
- Monolithic: All components of an application are tightly coupled and run as a single service. Easier to develop initially, harder to scale and maintain.
- Microservices: An application is built as a collection of small, independent services, each running in its own process and communicating via lightweight mechanisms. More complex to develop, but easier to scale, deploy, and maintain.
- Example: A traditional e-commerce app (Monolithic) vs. an e-commerce app with separate services for authentication, product catalog, shopping cart (Microservices).
- Answer:
- What is RESTful API?
- Answer: An architectural style for designing networked applications. It defines a set of constraints that clients and servers must adhere to for communication, typically over HTTP, using standard verbs (GET, POST, PUT, DELETE) and stateless operations.
- Example: GET /users/{id}, POST /products.
- What is caching? How does it improve performance?
- Answer: Storing frequently accessed data in a faster, temporary storage layer (cache) to reduce the time and cost of accessing it from its primary source. It improves performance by reducing latency and load on the main data source.
- Example: A web server caching popular page content to avoid repeated database queries.
- What is Load Balancing?
- Answer: The process of distributing network traffic across multiple servers to ensure no single server becomes a bottleneck. It improves performance, reliability, and availability.
- Example: Distributing incoming requests to an e-commerce website among several web servers.
- What is Idempotence?
- Answer: An operation is idempotent if applying it multiple times produces the same result as applying it once. Important for fault-tolerant systems and API design.
- Example: A DELETE /users/{id} request is idempotent; deleting a user multiple times still results in the user being deleted. A POST /orders is typically not idempotent (submitting twice creates two orders).
- What is Concurrency vs. Parallelism?
- Answer:
- Concurrency: Deals with managing multiple tasks that are in progress at the same time, giving the appearance of simultaneous execution (e.g., interleaving tasks on a single core).
- Parallelism: Deals with actually executing multiple tasks simultaneously (e.g., using multiple CPU cores).
- Example: A chef cooking multiple dishes by switching between them (concurrency); multiple chefs cooking different dishes at the same time (parallelism).
- Answer:
- What is containerization?
- Answer: A lightweight form of virtualization that packages an application along with all its dependencies (libraries, frameworks, configuration files) into a self-contained unit called a container.
- Example: Docker containers allow applications to run consistently across different environments.
- What is Continuous Integration (CI) and Continuous Delivery/Deployment (CD)?
- Answer:
- CI: A development practice where developers frequently integrate their code changes into a central repository, which are then automatically built and tested.
- CD: An extension of CI where code changes are automatically prepared for release to production (Delivery) or automatically deployed to production (Deployment) after passing all tests.
- Example: GitHub Actions or Jenkins pipelines automate code building, testing, and deployment.
- Answer:
- Explain CAPTCHA. How does it work? * Answer: Completely Automated Public Turing test to tell Computers and Humans Apart. It’s a type of challenge-response test used in computing to determine whether the user is human or not. It works by presenting a challenge that is easy for humans to solve but difficult for automated bots. * Example: Distorted text, image recognition tasks (“select all squares with traffic lights”).