Object Oriented Programming
CSE · Quiz · Fall 25
Paper 3 of 3By MD. ABDUR ROUF ROKON (2)Switch
Paper 3 of 3
Read the questions as text
Read off the PDF by AI, so it may have mistakes. The PDF is the original.
OOP
Quiz-2
1.Problem Scenario:
You are tasked with designing a University Student Management System.
The system includes:
- A Student who can enroll in multiple Courses.
- Each Course can have multiple Students enrolled (many-to-many relationship).
- Each Student has details such as studentID, name, and GPA.
- Each Course has details such as courseCode, courseName, and creditHours
Task:
- Describe how encapsulation helps protect sensitive information like GPA.
- Explain how the GPA should be updated securely using encapsulation principles.
2. Problem Scenario:
You are designing an Online Payment System that supports multiple payment methods.
The system includes:
- A base class Payment with a method processPayment().
- Subclasses: CreditCardPayment, PayPalPayment, and BankTransferPayment.
- Each subclass processes the payment differently - for example, credit cards require card validation, PayPal needs authentication, and bank transfer uses account verification.
Question:
1. Explain how runtime polymorphism helps in processing all payment types using a single Payment reference.
2. Describe how method overriding allows each subclass to define its own payment behavior.
3. Discuss the advantages of this approach if new payment types are added in the future.