Computer Science Interview Questions and Answers
Ques 6. Explain the difference between process and thread.
A process is an independent program with its memory space, while a thread is a lightweight unit of a process sharing the same memory space.
Example:
Process: Multiple instances of a web browser. Thread: Handling multiple tasks in a music player concurrently.
Ques 7. What is the purpose of the 'finally' block in exception handling?
The 'finally' block in exception handling always executes, whether an exception is thrown or not. It is used to release resources or perform cleanup tasks.
Example:
Closing a file or database connection in the 'finally' block.
Ques 8. Explain the concept of virtual memory.
Virtual memory is a memory management technique that provides an 'idealized abstraction' of the storage resources that are actually available on a given machine.
Example:
Using disk space as an extension of RAM when physical memory is full.
Ques 9. What is the difference between TCP and UDP?
TCP (Transmission Control Protocol) is a connection-oriented protocol that ensures reliable data delivery, while UDP (User Datagram Protocol) is a connectionless protocol with no guarantee of reliable data delivery.
Example:
TCP: File transfer. UDP: Real-time video streaming.
Ques 10. Explain the concept of a linked list.
A linked list is a linear data structure where elements are stored in nodes, and each node points to the next node in the sequence.
Example:
Singly linked list: Node1 -> Node2 -> Node3. Doubly linked list: Node1 <-> Node2 <-> Node3.
Most helpful rated by users:
- What is the difference between a stack and a queue?
- What is the purpose of an index in a database?
- What is the purpose of the 'git' version control system?