Java OOP Handwritten Notes
Java OOP Handwritten Notes
• Encapsulation
• Inheritance
• Abstraction
• Polymorphism
1. Encapsulation
Encapsulation means wrapping data and methods into a single unit (class) and hiding the data from
direct access using access modifiers.
How: private variables + public getters/setters
Why: Data security and controlled access
Example: ATM machine (balance is hidden)
2. Inheritance
Inheritance allows a child class to acquire properties and methods of a parent class using the
'extends' keyword.
Why: Code reusability and hierarchy
Example: Animal → Dog
Types:
• Single Inheritance
• Multilevel Inheritance
• Hierarchical Inheritance
3. Abstraction
Abstraction means hiding implementation details and showing only essential features to the user.
Achieved by: Abstract classes and Interfaces
Example: Car (we know how to drive, not engine internals)
• Reduces complexity
• Improves security
• Focuses on functionality
4. Polymorphism
Polymorphism means one method or object behaving in different ways.
Types:
• Improves reusability