Java OOP
OOP
OOP Concepts
Encapsulation
- Usually has 2 meanings in OOP
- Bundling of behavior and attributes on a single object
- The practice of hiding fields and methods from public access
- Why would we want to hide things?
- to make interface simplier
- hide unnecessary details
- protect integrity of data on an object
Inheritance
- Defines a is a relationship
- As a form of code re-use
- a way to organize classes into a parent-child hierarchy, which lets the child inherit (re-use), fields, methods from it’s parent
- A CHILD CAN ONLY HAVE 1 DIRECT PARENT THAT IT INHERITS FROM IN JAVA
Polymorphism
- simply means many forms
- makes code simpler
- it encourages code extensibility
Composition
- defines a has a relationship
- more flexible than inheritence
- you can add and remove composition components without the risk of breaking all of the subclasses that are inherited from like inheritence
Abstraction
This post is licensed under CC BY 4.0 by the author.