✏️ Explanatory Question

Differentiate between private and protected visibility modifiers.

👁 104 Views
📘 Detailed Answer
🟢 Easy
💡

Answer with Explanation

  • Private Modifier:

    • The most restrictive access level.
    • Members are accessible only within the same class.
  • Protected Modifier:

    • Allows access to members within the same package or through inheritance in subclasses, even if they are in different packages.