Skip to content

Object Oriented Programming Lab

SWE · Final · Spring 26

Paper 1 of 2By MAHMUDUL HASAN (1)Switch

Paper 1 of 2

This browser can’t show the PDF here

Open it, and your phone’s PDF viewer takes it, or download it.

Read the questions as text

Read off the PDF by AI, so it may have mistakes. The PDF is the original.

Question: Design a Java program for a Hospital Management System where each staff member has a name and base salary, and different roles calculate salary and bonus differently while supporting multiple staff types, data hiding, and dynamic storage. Create an interface BonusEligible with a method double calculateBonus(). Create an abstract class Staff that implements this interface, with private variables name and baseSalary, a constructor, and getter methods to demonstrate Encapsulation, and declare an abstract method double calculateSalary() to demonstrate Abstraction. Create two subclasses Doctor (with patientsHandled) and Nurse (with shifts) using Inheritance, and override both calculateSalary() and calculateBonus() in each subclass to demonstrate Polymorphism. Also demonstrate Method Overloading by creating two overloaded methods printDetails(), one that prints only the staff name and another that prints name, salary, and bonus. In the main method, use an ArrayList<Staff> to store at least three objects, and display all staff details using the overloaded methods. Marks: 30 Add Screenshots of your code and output. Viva: 10; Total=40