Java OOP Visuals
The Four Main Ideas of OOP
In the previous chapters, you learned the four main ideas of object-oriented programming (OOP): encapsulation, inheritance, polymorphism and abstraction.
This page shows all four ideas in pictures, with the same Animal, Pig and Dog classes. Each object is drawn as a box, with its data and its methods inside.
Visualize OOP
Choose an idea below, and click "Next step" to see how it works:
Summary
- Encapsulation: keep data private, and change it only through public methods. See Java Encapsulation.
- Inheritance: a child class gets the attributes and methods of its parent class. See Java Inheritance.
- Polymorphism: the same method call does different things, depending on the object. See Java Polymorphism.
- Abstraction: hide the details, and show only what is important. See Java Abstraction.