MSK Institute • Shikohabad
Loading Page Content...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Connecting serverPlease wait...
💻 Practical Labs🚀 Free Demo📜 Verified Certificates
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Encapsulation is the OOP mechanism of bundling data (attributes) and methods that manipulate that data into a single unit while restricting direct outside access. In Java, this is governed by 4 Access Levels.
| Modifier | Inside Same Class | Inside Same Package | Subclasses (Different Package) | World (Everywhere) |
|---|---|---|---|---|
public | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
protected | ✅ Yes | ✅ Yes | ✅ Yes (via inheritance) | ❌ No |
| (default / package-private) | ✅ Yes | ✅ Yes | ❌ No | ❌ No |
private | ✅ Yes | ❌ No | ❌ No | ❌ No |
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Test your understanding of this lesson with 1 questions. Each question has one correct answer.