How many types of access specifiers are provided in OOP (C++)?

Options

  • A. 2
  • B. 1
  • C. 4
  • D. 3

Correct Answer (Detailed Explanation is Below)

D. 3

Detailed Explanation

Explanation:

In C++, there are 3 access specifiers:

  1. public → Accessible from anywhere

  2. private → Accessible only within the class

  3. protected → Accessible within the class and derived classes

So, the total number of access specifiers in C++ is 3.

OOps! You are currently offline.