Multiple choice technology programming languages

You can give a property an accessibility higher than the declaring class?

  1. True

  2. False

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Property accessibility cannot exceed the accessibility level of its declaring class. For example, if a class is private, you cannot declare a public property within it. This maintains encapsulation and access control principles in object-oriented programming.

AI explanation

In languages like C#/Java, a member (property, method, field) cannot be given broader effective accessibility than the type that declares it — a public property inside an internal/package-private class doesn't actually become externally accessible from outside the assembly/package, because the containing type's accessibility caps what callers can reach. The compiler may allow the syntax in some cases, but the effective accessibility is bounded by the declaring class, so you cannot truly grant a member higher accessibility than its class allows — hence 'False' is correct.