Advertisements
Advertisements
Question
A private member method is only accessed:
Options
In the scope of the same class in which it is defined.
Anywhere outside the class in which it is defined.
In the derived class.
None of the above.
MCQ
Solution
In the scope of the same class in which it is defined.
Explanation:
In Java, private member methods are accessible only within the class in which they are declared. The private access modifier limits the method's visibility, preventing direct access from outside the class or from derived classes.
shaalaa.com
Is there an error in this question or solution?