What is Oop?
Oop(Object-Oriented Programming) is a method of programming where we organize code like real-world things.
Classes → blueprint
Objects → real things created from classExample:
Class = Car design
Object = Actual car
Main Concepts of Oop
1) Polymorphism (Many Forms)
Same method name, different behavior
Example: Same method → pay()
But different behavior:
Credit Card → pay via card
UPI → pay via mobile
Net Banking → pay via bank
2) Inheritance (Reuse)
One class can use properties of another class
Example: Vehicle System
Parent class → Vehicle
Child classes → Car, Bike
All vehicles have: Speed, Fuel
Car & Bike can reuse these properties
3) Abstraction (Hide Details)
Show only important things, hide internal details
Example: ATM Machine
We just:
Insert card
Enter PIN
Withdraw money
We don’t know:
how money is processed
how server works
✔ Only important things shown
✔ Internal logic hidden
4) Encapsulation (Data Hiding)
Wrapping data + methods together in one class
Example: Bank Account
Balance is hidden
Cannot directly change it
Must use methods like: deposit(), withdraw()
You can’t access balance directly
Data is safe
Top comments (0)