Which of the following is an access specifier?

particular
shielded
protected
safe

The correct answer is C. protected.

An access specifier is a keyword that controls the accessibility of a member of a class. The four access specifiers in C++ are public, protected, private, and internal.

  • Public members are accessible from any class.
  • Protected members are accessible from classes derived from the class in which they are declared.
  • Private members are only accessible from the class in which they are declared.
  • Internal members are accessible from classes in the same translation unit.

The keyword protected is used to declare a member that is accessible from classes derived from the class in which it is declared. This is useful for ensuring that only derived classes can access certain members, and that these members are not directly accessible from other classes.

The keywords particular, shielded, and safe are not valid access specifiers in C++.

Exit mobile version