-
Question: 26. What is process scheduling? Explain different types of schedulers.
Answer: Process scheduling determines the execution order of processes. Types include long-term, short-term, and medium-term schedulers.
-
Question: 27. How does virtual memory work?
Answer: Virtual memory uses disk space as an extension of RAM, allowing processes to execute beyond physical memory limits.
-
Question: 28. Explain deadlock and how it can be prevented.
Answer: Deadlock is a situation where processes wait indefinitely for resources. Prevention includes resource ordering and avoiding circular waits.
-
Question: 29. What is the difference between process and thread?
Answer: A process is an independent executing instance, while a thread is a lightweight unit of execution within a process.
-
Question: 30. Describe the Round Robin scheduling algorithm.
Answer: Round Robin assigns time slices to processes in a cyclic order, ensuring fair CPU time distribution.
-
Question: 31. Explain the concept of paging and segmentation.
Answer: Paging divides memory into fixed-size blocks, while segmentation divides it into variable-size logical segments.
-
Question: 32. What are race conditions? How can they be avoided?
Answer: Race conditions occur when multiple threads access shared resources simultaneously. They can be avoided using locks, mutexes, or semaphores.
-
Question: 33. How does the banker's algorithm prevent deadlock?
Answer: The banker's algorithm ensures resources are allocated safely by checking if allocation would leave the system in a safe state.
-
Question: 34. Explain the difference between preemptive and non-preemptive scheduling.
Answer: Preemptive scheduling allows process interruption, while non-preemptive scheduling completes a process before switching.
-
Question: 35. What is a system call, and how does it work?
Answer: A system call is a user-space request to the kernel for services like file operations or process control.
-
Question: 36. Describe the difference between multitasking and multithreading.
Answer: Multitasking runs multiple processes, while multithreading runs multiple threads within a process.
-
Question: 37. What is context switching? When does it occur?
Answer: Context switching is saving a process state and restoring another. It occurs during process scheduling or interrupts.
-
Question: 38. What is the purpose of a mutex in process synchronization?
Answer: A mutex ensures only one thread accesses a critical section at a time to prevent race conditions.
-
Question: 39. Explain inter-process communication (IPC).
Answer: IPC allows processes to exchange data using mechanisms like shared memory, message passing, or pipes.
-
Question: 40. What are the differences between monolithic kernels and microkernels?
Answer: Monolithic kernels manage all OS functions, while microkernels handle core services, delegating others to user space.
-
Question: 41. How does demand paging work in virtual memory?
Answer: Demand paging loads pages into memory only when needed, reducing memory usage.
-
Question: 42. What are inodes in file systems?
Answer: Inodes store metadata about files, like size, permissions, and disk block locations.
-
Question: 43. What is the difference between paging and swapping in memory management?
Answer: Paging moves memory pages between RAM and disk, while swapping moves entire processes.
-
Question: 44. Describe thrashing and how it can be avoided.
Answer: Thrashing occurs when excessive paging reduces performance. It can be avoided by allocating sufficient memory or adjusting multiprogramming levels.
-
Question: 45. How do signal handlers work in UNIX/Linux systems?
Answer: Signal handlers execute specific functions when a process receives a signal, overriding default behavior.
-
Question: 46. What is scheduling starvation, and how can it be resolved?
Answer: Starvation occurs when low-priority processes are indefinitely delayed. It can be resolved using aging to increase priority over time.
-
Question: 47. Explain the concept of priority inversion and its solution.
Answer: Priority inversion occurs when a high-priority task waits for a lower-priority task. Solutions include priority inheritance.
-
Question: 48. What is the role of a scheduler in an operating system?
Answer: The scheduler manages CPU allocation to processes, optimizing performance and resource utilization.
-
Question: 49. How does process synchronization prevent race conditions?
Answer: Process synchronization uses mechanisms like locks, semaphores, and monitors to ensure safe shared resource access.
-
Question: 50. What are the different states of a process lifecycle?
Answer: Process states include new, ready, running, waiting, and terminated.
-
3. Databases
-
Question: 51. What is normalization, and why is it important?
Answer: Normalization organizes data to reduce redundancy and improve data integrity.
-
Question: 52. Explain ACID properties in databases.
Answer: ACID stands for Atomicity, Consistency, Isolation, and Durability, ensuring reliable transactions.
-
Question: 53. What is a foreign key? How does it differ from a primary key?
Answer: A foreign key links tables and references a primary key in another table; a primary key uniquely identifies a record.
-
Question: 54. What is the difference between SQL and NoSQL databases?
Answer: SQL databases are relational and use structured schemas, while NoSQL databases are non-relational and handle unstructured data.
-
Question: 55. How would you optimize a slow-running SQL query?
Answer: By indexing, analyzing query plans, optimizing joins, and avoiding SELECT *.
-
Question: 56. Explain transaction isolation levels in databases.
Answer: Isolation levels (READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE) define how transactions interact with each other.
-
Question: 57. What are triggers and when would you use them?
Answer: Triggers are automatic actions executed in response to certain database events.
-
Question: 58. Explain the concept of indexing and how it improves database performance.
Answer: Indexing creates a data structure to allow faster search and retrieval.
-
Question: 59. How does database partitioning work?
Answer: Partitioning divides data into smaller segments for improved manageability and performance.
-
Question: 60. What is a JOIN in SQL, and what are the different types of joins?
Answer: JOIN combines data from multiple tables. Types include INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN.
-
Question: 61. What is a view in a database? How is it different from a table?
Answer: A view is a virtual table based on a query, whereas a table physically stores data.
-
Question: 62. Explain the difference between HAVING and WHERE clauses in SQL.
Answer: WHERE filters rows before aggregation; HAVING filters after aggregation.
-
Question: 63. What are stored procedures? How do they differ from functions?
Answer: Stored procedures perform tasks and can return multiple values, while functions return a single value.
-
Question: 64. Explain the concept of sharding in distributed databases.
Answer: Sharding partitions data across multiple servers for scalability.
-
Question: 65. How does deadlock occur in databases? How can it be resolved?
Answer: Deadlock occurs when transactions wait indefinitely for resources. It can be resolved by timeouts or deadlock detection algorithms.
-
Question: 66. What is a schema in a database?
Answer: A schema defines the structure of a database, including tables, columns, and relationships.
-
Question: 67. How do cascading deletes work in relational databases?
Answer: Cascading deletes automatically remove dependent rows when a referenced row is deleted.
-
Question: 68. What is denormalization, and when is it beneficial?
Answer: Denormalization combines tables to improve read performance, often used in analytics.
-
Question: 69. How would you implement pagination in a SQL query?
Answer: By using LIMIT and OFFSET or ROW_NUMBER.
-
Question: 70. What are database locks, and what are their types?
Answer: Locks prevent concurrent access issues. Types include shared, exclusive, and row-level locks.
-
Question: 71. What are aggregate functions in SQL? Give examples.
Answer: Aggregate functions perform calculations on multiple rows. Examples: COUNT(), AVG(), MAX(), MIN(), SUM().
-
Question: 72. How would you enforce referential integrity in a relational database?
Answer: By using foreign keys with constraints like ON DELETE and ON UPDATE.
-
Question: 73. Explain the differences between horizontal and vertical scaling in databases.
Answer: Horizontal scaling adds more servers; vertical scaling increases server capacity.
-
Question: 74. How does replication work in databases?
Answer: Replication copies data from one server to others for redundancy and scalability.
-
4. Object-Oriented Programming (OOP)
-
Question: 75. What is inheritance in OOP? Explain with an example.
Answer: Inheritance allows one class to derive properties and behaviors from another. Example: A Dog class inherits from an Animal class.
-
Question: 76. What is the difference between polymorphism and overloading?
Answer: Polymorphism allows one interface with multiple implementations; overloading defines multiple methods with the same name but different parameters.
-
Question: 77. How do abstract classes differ from interfaces?
Answer: Abstract classes can have implementations; interfaces only define methods without implementation.
-
Question: 78. Explain the concept of encapsulation in OOP.
Answer: Encapsulation restricts direct access to an object's data, exposing only necessary parts.
-
Question: 79. What is constructor chaining in object-oriented programming?
Answer: Constructor chaining occurs when one constructor calls another in the same or a parent class.
-
Question: 80. How would you implement multiple inheritance in a language that doesn't support it directly (e.g., Java)?
Answer: By using interfaces.
-
Question: 81. What is the diamond problem, and how is it resolved?
Answer: The diamond problem occurs with multiple inheritance when a class inherits the same base class via different paths. It is resolved using virtual inheritance or interfaces.
-
Question: 82. Explain method overriding and how it differs from overloading.
Answer: Overriding changes a method's behavior in a subclass; overloading defines multiple methods with the same name but different parameters.
-
Question: 83. What are design patterns? Give an example of a singleton pattern.
Answer: Design patterns are reusable solutions to common problems. Singleton ensures a class has only one instance.
-
Question: 84. Explain the SOLID principles of object-oriented design.
Answer: SOLID principles ensure maintainable and scalable OOP designs: Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, Dependency Inversion.
-
Question: 85. What is the difference between aggregation and composition in OOP?
Answer: Composition implies ownership and lifecycle management; aggregation does not.
-
Question: 86. How does late binding work in polymorphism?
Answer: Late binding resolves method calls at runtime, allowing dynamic method invocation.
-
Question: 87. Explain dependency injection and its benefits.
Answer: Dependency injection provides objects their dependencies, improving testability and modularity.
-
Question: 88. What are access modifiers in OOP? Explain the difference between public, private, and protected.
Answer: Access modifiers control visibility. Public: accessible everywhere; Private: within the class; Protected: within the class and subclasses.
-
Question: 89. How is exception handling implemented in OOP languages?
Answer: Using try-catch blocks, custom exceptions, and finally blocks.
-
Question: 90. What is a virtual function, and why is it used?
Answer: A virtual function allows method overriding in derived classes for runtime polymorphism.
-
Question: 91. What is the Liskov Substitution Principle?
Answer: Subtypes must be substitutable for their base types without altering functionality.
-
Question: 92. How does garbage collection work in OOP languages like Java?
Answer: Garbage collection automatically reclaims memory by identifying and removing unused objects.
-
Question: 93. What is the difference between shallow copy and deep copy of objects?
Answer: Shallow copy copies references, not objects; deep copy duplicates objects entirely.
-
Question: 94. What is static binding, and when does it occur?
Answer: Static binding occurs at compile time, binding methods to calls based on the declared type.
-
Question: 95. What is duck typing in object-oriented languages?
Answer: Duck typing determines object compatibility based on methods and properties rather than inheritance.
-
5. Networking
-
Question: 96. What is the OSI model? Explain each layer.
Answer: The OSI model has 7 layers: Physical, Data Link, Network, Transport, Session, Presentation, Application, each handling specific network functions.
-
Question: 97. What is the difference between TCP and UDP?
Answer: TCP is connection-oriented and reliable; UDP is connectionless and faster but less reliable.
-
Question: 98. How does HTTP work, and what are HTTP status codes?
Answer: HTTP is a request-response protocol. Status codes indicate the response type (e.g., 200 OK, 404 Not Found).
-
Question: 99. What is DNS and how does it resolve domain names?
Answer: DNS translates domain names to IP addresses using a hierarchical lookup.
-
Question: 100. Explain the concept of IP addressing and subnetting.
Answer: IP addressing assigns unique identifiers; subnetting divides networks into smaller segments for efficient use.
-
Question: 101. What is ARP (Address Resolution Protocol)?
Answer: ARP maps IP addresses to MAC addresses in a local network.
-
Question: 102. Explain the difference between IPv4 and IPv6.
Answer: IPv4 uses 32-bit addresses; IPv6 uses 128-bit addresses and offers better scalability and security.
-
Question: 103. What are the differences between firewall and proxy?
Answer: A firewall filters network traffic; a proxy acts as an intermediary for requests.
-
Question: 104. What is SSL/TLS, and how does it provide security?
Answer: SSL/TLS encrypts data in transit for secure communication.
-
Question: 105. What is the difference between a router and a switch?
Answer: A router connects networks; a switch connects devices within a network.
-
Question: 106. Explain the concept of network congestion control.
Answer: Congestion control manages data flow to prevent overwhelming the network.
-
Question: 107. What is NAT (Network Address Translation), and why is it used?
Answer: NAT translates private IP addresses to a public IP, conserving IP addresses.
-
Question: 108. Explain the role of load balancers in networking.
Answer: Load balancers distribute traffic across multiple servers to ensure availability and performance.
-
Question: 109. What is ICMP, and what is its purpose?
Answer: ICMP diagnoses network issues, sending error messages (e.g., ping).
-
Question: 110. What is the difference between a VPN and a VLAN?
Answer: A VPN secures communication over the internet; a VLAN groups devices in a virtual network.