ch 2 oops
1️⃣ Encapsulation (C++) 🔹 Definition Encapsulation means wrapping data (variables) and methods (functions) together into a single unit called a class , and restricting direct access to data. 👉 Achieved using: private protected public 🔹 Why Needed? Data security Prevents unauthorized access Controls modification 🔹 Example in C++ #include <iostream> using namespace std ; class BankAccount { private : double balance; // Hidden data public : void deposit( double amount ) { balance += amount ; } double getBalance() { return balance ; } }; int main () { BankAccount obj ; obj .deposit( 5000 ); cout << obj .getBalance(); } ✅ balance cannot be accessed directly. This is data hiding + encapsulation . 2️⃣ Data Abstraction (C++) 🔹 Definition Abstraction means hiding internal implementation details and showing only essential features. 👉 Real Example: ATM machine — you pre...