Advertisements
Advertisements
Question
Find the access specifier which prohibits a class member from being used outside a class:
Options
Private
Public
Protected
None
MCQ
Solution
Private
Explanation:
When a class member (such as a variable or method) is marked as private, it is inaccessible from outside the class. It can only be accessed within the same class where it was declared. This enables encapsulation by prohibiting direct access to the class's internal details.
shaalaa.com
Is there an error in this question or solution?