📎 Webclip
Object Oriented Programming Concepts Explained
The page defines object oriented programming as the use of objects that contain both data and methods that interact with each other. It says a language needs objects, classes, encapsulation, inheritance, abstraction, and polymorphism to count as object oriented.
Reading notes#
- Encapsulation keeps an object’s state private and lets other objects change it only through public methods.
- The cat example shows private fields and a private meow() method, with public methods like Sleep, Play, and Feed changing the state.
- Inheritance creates a hierarchy where child classes reuse fields and methods from a parent class and add their own unique methods.
- The teacher and student example shows both as Person classes, with subject for Teacher and school for Student.
- Abstraction shows only a high-level interface and hides internal implementation details from other objects.
- The cell phone example says users know what the buttons do without knowing how they work behind the scenes.
- Polymorphism means one interface can be used by different object types, each with its own version of that interface.
- The figure example says star, circle, and rectangle share methods like calculateSurface() and calculatePerimeter(), but each computes them differently.
