arrow
arrow
arrow
The number of access specifiers in a class of C++ is
Question

The number of access specifiers in a class of C++ is

A.

2

B.

3

C.

4

D.

More than one of the above

E.

None of the above

Correct option is B

The number of access specifiers in a class of C++ is 3. These specifiers—public, private, and protected—play a critical role in controlling the visibility and accessibility of the class members.
Important Key Points:
1. Public: Members declared as public are accessible from anywhere in the program. This access specifier is used when members need to be available outside the class.
2. Private: Members with private access are only accessible within the class itself or by friend functions. This ensures encapsulation and data protection.
3. Protected: Protected members can be accessed within the class and its derived classes. This specifier is useful for inheritance and restricting external access.

Free Tests

Free
Must Attempt

General Science : Subject Test - 01

languageIcon English
  • pdpQsnIcon20 Questions
  • pdpsheetsIcon40 Marks
  • timerIcon15 Mins
languageIcon English
Free
Must Attempt

Chapter Test : General Physics - 01

languageIcon English
  • pdpQsnIcon30 Questions
  • pdpsheetsIcon60 Marks
  • timerIcon18 Mins
languageIcon English
Free
Must Attempt

Indus Valley Civilization

languageIcon English
  • pdpQsnIcon10 Questions
  • pdpsheetsIcon10 Marks
  • timerIcon5 Mins
languageIcon English
test-prime-package

Access ‘BPSC TRE (11-12)’ Mock Tests with

  • 60000+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
246k+ students have already unlocked exclusive benefits with Test Prime!
Our Plans
Monthsup-arrow