Join Peggy Fisher for an in-depth discussion in this video Working with polymorphism, part of Learning Java.
- I'd like to wrap up this section with one more term that you'll hear a lot when dealing with object-oriented programming. That term is polymorphism, similar to the inheritance and encapsulation, this is also a benefit of object-oriented programming. When we use Inheritance to create new classes, each new class inherits both the data members and methods of the base class. But sometimes, the methods need to behave differently depending on the new class definition. For example: remember our bug class? We used this class as a base for creating more specific types of bug classes, such as Grasshopper and Ladybug.
If we wanted to simulate a grasshopper moving, it would jump. But when a ladybug moves, it flies. The same word move has two implementations. This problem can be solved using polymorphism. It enables one common interface for many implementations and for objects to act differently under different circumstances. So the bug class would have a generic move method defined that crawls. An ant can use the base method because an ant crawls, but each of the inherited classes would redefine this method with their specific types of move methods.
For more detailed information and examples of polymorphism, please visit Foundations of Programming: Object-Oriented Design with Simon Allardice, specifically the video "What is polymorphism".
- Downloading and exploring NetBeans
- Understanding Java basics: data types, strings, arrays, and more
- Controlling flow with functions and loops
- Creating classes
- Sorting and searching arrays
- Manipulating files
- Handling errors
- Building GUIs
Skill Level Beginner
1. Getting Started
2. Java Basics
3. Flow of Control
4. Classes and Objects
5. Beyond the Basics
6. File Manipulation
7. Graphical User Interface Basics
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.