Sample Computer Science Examination with Solutions, Assignments of Computer Science

Need to prep for your CS exams? This solved exam paper has 8 exam-style questions with answers, covering everything from OOP, SQL queries, networking (TCP vs UDP), OS synchronization, and more. Great for university-level Computer Science students

Typology: Assignments

2024/2025

Available from 08/20/2025

dunchin-lampini
dunchin-lampini ๐Ÿ‡บ๐Ÿ‡ธ

2 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Computer Science Examination
Instructions:
1. Answer ALL questions.
2. Show all workings where applicable.
3. Time allowed: 2 Hours.
4. Each question carries equal marks unless otherwise stated.
1. Explain the difference between a compiler and an interpreter.
Answer:
A compiler translates the entire program into machine code before execution, producing an
executable file. An interpreter translates and executes the program line by line, without producing a
separate executable.
2. Write a SQL query to retrieve all students with marks above 70 from a table named
Students.
Answer:
SQL Query:
SELECT * FROM Students WHERE marks > 70;
3. Describe three differences between TCP and UDP.
Answer:
- TCP is connection-oriented, UDP is connectionless.
- TCP guarantees reliable delivery, UDP does not.
- TCP has higher overhead due to error-checking and acknowledgments, UDP is faster with less
overhead.
4. Explain the concept of process synchronization in operating systems.
Answer:
Process synchronization ensures that multiple processes can operate safely when accessing
shared resources, preventing race conditions and ensuring data consistency. Common
mechanisms include semaphores, mutexes, and monitors.
5. List and briefly explain the four principles of Object-Oriented Programming (OOP).
Answer:
1. Encapsulation โ€“ Bundling data with methods.
2. Abstraction โ€“ Hiding unnecessary details.
3. Inheritance โ€“ Deriving new classes from existing ones.
4. Polymorphism โ€“ One interface, multiple implementations.
6. A password system stores hashes instead of plaintext passwords. Explain why this is
important.
Answer:
Storing hashes increases security by preventing attackers from directly obtaining user passwords if
the database is compromised. Even if hashes are stolen, reversing them is computationally difficult,
especially with salted hashes.
7. Differentiate between Waterfall and Agile models in Software Engineering.
pf2

Partial preview of the text

Download Sample Computer Science Examination with Solutions and more Assignments Computer Science in PDF only on Docsity!

Computer Science Examination

Instructions:

  1. Answer ALL questions.
  2. Show all workings where applicable.
  3. Time allowed: 2 Hours.
  4. Each question carries equal marks unless otherwise stated. 1. Explain the difference between a compiler and an interpreter.

Answer: A compiler translates the entire program into machine code before execution, producing an executable file. An interpreter translates and executes the program line by line, without producing a separate executable.

2. Write a SQL query to retrieve all students with marks above 70 from a table named Students.

Answer: SQL Query: SELECT * FROM Students WHERE marks > 70;

3. Describe three differences between TCP and UDP.

Answer:

  • TCP is connection-oriented, UDP is connectionless.
  • TCP guarantees reliable delivery, UDP does not.
  • TCP has higher overhead due to error-checking and acknowledgments, UDP is faster with less overhead. 4. Explain the concept of process synchronization in operating systems.

Answer: Process synchronization ensures that multiple processes can operate safely when accessing shared resources, preventing race conditions and ensuring data consistency. Common mechanisms include semaphores, mutexes, and monitors.

5. List and briefly explain the four principles of Object-Oriented Programming (OOP).

Answer:

  1. Encapsulation โ€“ Bundling data with methods.
  2. Abstraction โ€“ Hiding unnecessary details.
  3. Inheritance โ€“ Deriving new classes from existing ones.
  4. Polymorphism โ€“ One interface, multiple implementations. 6. A password system stores hashes instead of plaintext passwords. Explain why this is important.

Answer: Storing hashes increases security by preventing attackers from directly obtaining user passwords if the database is compromised. Even if hashes are stolen, reversing them is computationally difficult, especially with salted hashes.

7. Differentiate between Waterfall and Agile models in Software Engineering.

Answer: Waterfall is a sequential model with distinct phases (requirements โ†’ design โ†’ implementation โ†’ testing โ†’ deployment). Agile is iterative, adaptive, and involves continuous feedback and incremental development.

8. Write a simple Python program to check if a number is prime.

Answer: Python Code: def is_prime(n): if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True print(is_prime(7))