CS FundamentalsHardGATE CS · TCS NQT Prime · Product Company SDE

A class diagram marks an attribute's visibility with a '#' symbol before its name. What does this denote?

  1. A. Public visibility, accessible from anywhere
  2. B. Protected visibility: accessible to the class itself and its subclasses, but not to unrelated classes
  3. C. Private visibility, accessible only within the class itself
  4. D. Package (default) visibility, accessible only within the same package

Correct answer: B. Protected visibility: accessible to the class itself and its subclasses, but not to unrelated classes

UML uses '+' for public, '-' for private, '#' for protected and '~' for package visibility; '#' specifically marks a member as accessible to the class and its subclasses, but hidden from unrelated external code.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic