It is a programming approach that organizes code into object and classes and make it more structured and easy to use. Java Follows DRY (Don’t Repeat Yourself)
Four main pillars of object oriented programming
- Abstraction
- Encapsulation
- Inheritance
- Polymorphism
Abstraction
Only essential details are displayed to the user In hava it is achieved via Interfaces and Abstract classes
Encapsulation
Wrapping up of the data into a single unit data-hiding Variables are private and the methods are public
Inheritance
- Mechanism to inherit the features of some class
- Also known as is-a relationship
- Super class vs Sub class
- Reusability
- Use
extends
keyword
Polymorphism
Ability to differentiate between entities with same name efficiently
Types of Polymorphism
- Method overloading / compile time
- Method overriding / runtime