Merit Higher Institute of Technology
Department of Computer Science
Course Title: Object-Oriented Programming
Course Code: CSC 221
Duration: 2 Hours
Exam Type: Second Semester Exam
Total Marks: 70 Marks
Instructor: Prof. Naha.F
INSTRUCTIONS:
Answer ALL questions.
Write your answers clearly and legibly.
Ensure all workings are shown where applicable.
This paper is divided into two sections (A & B).
Use the marks allocated to each question as a guide.
SECTION A: Scenario-Based Essay & Application
(40Marks)
Case Study: The RideShare App
As part of a software engineering team, you’ve been asked to help design the backend of a new
RideShare application, similar to Uber. The system should allow Drivers to register and add
their cars. Customers should be able to request rides and be matched with available drivers. The
system should also keep a history of completed rides and allow for both users to rate each other.
Your manager is keen on implementing this using Object-Oriented Programming principles
to make the codebase scalable and maintainable. You have decided to model your solution using
classes and objects, leveraging inheritance, polymorphism, abstraction, and encapsulation.
Using this scenario, answer the following questions:
Questions – Section A (30 Marks)
1. Identify at least four main classes that would be necessary for building this system. For each
class, list at least three attributes and two methods. (8 marks)
2. Describe how inheritance could be applied in this system. Illustrate your answer with a
suitable example from your identified classes. (5 marks)
3. Explain how polymorphism could be useful in handling the rating system between drivers
and customers. Give a brief code sketch or pseudocode. (5 marks)
4. Discuss how the principle of encapsulation helps to improve the security or maintainability of
this application. Provide an example using one class. (4 marks)
5. Design a basic UML class diagram representing your four main classes and their
relationships. Use appropriate symbols for inheritance or associations. (8 marks)
SECTION B: Multiple Choice and Structured Questions
(10Marks)
Part I: Multiple Choice Questions – Choose the Most Appropriate Answer (10 ×
1 = 10 Marks)
6. Which of the following best describes encapsulation in OOP?
A. Hiding the implementation details of a class
B. Combining different classes into one
C. Deriving new classes from existing ones
D. Making all attributes public
7. Which of these concepts allows one interface to be used for a general class of actions?
A. Inheritance
B. Polymorphism
C. Abstraction
D. Composition
8. What is the purpose of a constructor in a class?
A. It deletes the object
B. It defines how data is hidden
C. It initializes an object when it is created
D. It creates an interface
9. Which keyword is used in most OOP languages to inherit a class?
A. uses
B. this
C. extends
D. import
10. Which of the following is NOT a feature of OOP?
A. Reusability
B. Modularity
C. Security
D. Sequential flow
11. What is method overloading?
A. Defining the same method in child and parent class
B. Defining multiple methods with the same name but different parameters in the same class
C. Using private methods in subclasses
D. None of the above
12. Which of the following is an example of a class?
A. 23
B. “Hello”
C. Student
D. print()
13. Which of the following types of relationships does inheritance model?
A. Has-A
B. Uses-A
C. Is-A
D. Owns-A
14. What does the term abstraction mean in OOP?
A. Hiding the data
B. Hiding internal implementation and showing only necessary features
C. Creating detailed data models
D. None of the above
15. What is the access modifier that allows attributes or methods to be accessed only within the
class?
A. Public
B. Private
C. Protected
D. Static
Part II: Structured Questions (20 Marks)
16. (5 Marks)
Write a class named Person in a language of your choice. The class should have the following
attributes: name, email, and phoneNumber.
Add a constructor to initialize these attributes, and a method displayInfo() to print out the
person's details.
17. (5 Marks)
Assume you have a superclass called Vehicle, and two subclasses Car and Motorcycle.
a) Demonstrate how you would implement inheritance.
b) Add one method that is overridden in both Car and Motorcycle.
18. (5 Marks)
Explain with an example how abstraction differs from encapsulation in OOP.
19. (5 Marks)
List and explain four (4) benefits of Object-Oriented Programming over Procedural
Programming.
20. (5 Marks)
Convert the following procedural code into object-oriented code (in pseudocode or any OOP
language):
// Procedural code
name = "Alice"
age = 25
print(name + " is " + str(age) + " years old")
21. (5 Marks)
Explain the difference between static and instance methods in OOP. Provide an example for
each.
MARKING GUIDE
Section A (30 Marks)
Question Points Marking Criteria
Q1 8 2 marks per class (attributes + methods)
Q2 5 Explanation (2), Example (3)
Q3 5 Clear concept of polymorphism (2), Code sketch (3)
Q4 4 Theory (2), Example (2)
Q5 8 Correct UML (4 classes, relationships shown, syntax)
Section B (40 Marks)
Part I: Multiple Choice (10 Marks)
1 mark per correct answer. Correct answers:
6:A, 7:B, 8:C, 9:C, 10:D, 11:B, 12:C, 13:C, 14:B, 15:B
Part II: Structured (30 Marks)
Question Points Marking Criteria
Q16 5 Correct class structure (2), Constructor (1.5), displayInfo method (1.5)
Q17 5 Proper inheritance syntax (2), Method overriding in both subclasses (3)
Q18 5 Clear contrast + examples (2.5 each)
Q19 5 1.25 marks per benefit clearly explained
Q20 5 Valid OOP rewrite (attributes, class, method)
Q21 5 Explanation (2.5), Examples (2.5)