Home / Questions / Differentiate between private and protected visibility modifiers.
Explanatory Question

Differentiate between private and protected visibility modifiers.

👁 104 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

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.