From the course: Object-Oriented Programming with Java
Unlock this course with a free trial
Join today to access over 22,400 courses taught by industry experts.
Exercise: Polymorphism - Java Tutorial
From the course: Object-Oriented Programming with Java
Exercise: Polymorphism
- [Narrator] If you'd like to try exercising your powers of polymorphism, here's a suggested exercise. This UML describes the relationships between a doctor, a general practitioner, and a surgeon, and as you can see, there's a parent/child class between doctor and general practitioner and also between doctor and surgeon. We can also say that general practitioner is a doctor and surgeon is a doctor. So when you go to implement this, you're going to want to override the doMedicine method because a general practitioner does medicine differently to a surgeon. A surgeon performs surgery. A general practitioner makes house calls. Good luck!
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.