Methods declared with the following modifier are not accessible outside the class
-
Private
-
Protected
-
Friend
-
Global
To answer this question, the user needs to know about access modifiers in object-oriented programming and their purpose in controlling the scope of class members.
A. Private: This option is correct. Private methods are only accessible within the class they are declared in. They cannot be accessed by other classes, even if they inherit from the same parent class.
B. Protected: This option is incorrect. Protected methods are accessible within the class they are declared in and any subclasses that inherit from the parent class. They cannot be accessed by external classes.
C. Friend: This option is incorrect. Friend methods are a C++ specific feature that allow one class to access the private members of another class. They are not available in other programming languages.
D. Global: This option is incorrect. Global methods are available to all classes and can be accessed from anywhere in the program.
Therefore, the answer is: A
The private access modifier restricts a member so it can only be called from within the same class where it's declared — no other class, including subclasses, can see or invoke it. This is the strictest access level, contrasted with protected (visible to subclasses), and broader modifiers like Friend/internal or public-equivalent scopes that expose members more widely.