Difficulty: Easy
Correct Answer: Protected
Explanation:
Introduction / Context:
C++ provides three access specifiers to control the visibility of class members: public, protected, and private. Choosing the correct specifier is fundamental to encapsulation, information hiding, and safe inheritance hierarchies. This question asks you to identify the keyword among the options that actually serves as an access-control specifier.
Given Data / Assumptions:
Concept / Approach:
Access specifiers determine who can see or use class members. Inheritance also interprets them: under public inheritance, public stays public, protected stays protected, and private remains inaccessible to derived classes. Among the choices, only protected is a real access specifier. The others either have different purposes or are not standard C++ keywords for access control.
Step-by-Step Solution:
Verification / Alternative check:
Write a sample class and mark a member as protected. Attempt access from outside the class (fails) and from a derived class (succeeds), demonstrating the role of the protected specifier.
Why Other Options Are Wrong:
Default: no such access specifier keyword; “default access” is contextual (class vs. struct).
Break: used to exit loops/switch, not for access control.
Asm: non-standard/extension keyword for inline assembly, unrelated to access.
Common Pitfalls:
Final Answer:
Protected
Discussion & Comments