A Java console application that models hospital personnel and demonstrates foundational OOP concepts:
Encapsulation, Inheritance, Method Overriding, Upcasting, and Downcasting.
Build a straightforward Hospital Management System in Java where different roles share common structure but expose role-specific behavior, illustrating how object-oriented design maps to real-world entities.
- Base class
Personwith private fields:name(String)age(int)gender(String)
- Accessible through public getters and setters.
- Four subclasses extending
Person:Doctorβ addsspecialization(String)Nurseβ addsqualification(String)Patientβ addsdisease(String)Receptionistβ addsshift(String)
- Each subclass overrides a
details()method to print its own information.
- Upcasting: Treat
Doctor,Nurse,Patient, andReceptionistasPersonreferences to demonstrate polymorphism. - Downcasting: Safely revert to subclasses (with
instanceofchecks) to access their specific fields.
βββ src/
β βββ Hms/
β βββ Person.java
β βββ Doctor.java
β βββ Nurse.java
β βββ Patient.java
β βββ Receptionist.java
β βββ Main.java # entry point
β βββ module-info.java
βββ .classpath
βββ .project
βββ .gitignore
βββ README.md
name: Dr. Alekhya, age: 33, gender: Female
Doctor Specialization :Neuro
----------------------------------
name: Ravi, age: 60, gender: Male
Patient disease :Braintumor
----------------------------------
name: Mamatha, age: 32, gender: Female
Reciptionist Shift :night
----------------------------------
name: Ramu, age: 29, gender: Male
Nurse Qualification :nursing
----------------------------------- Java (OOP Concepts)
- Eclipse IDE (or any preferred Java IDE)