English

A private member method is only accessed: - Computer Applications

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?
Chapter 8: Encapsulation and Inheritance - EXERCISES [Page 444]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 8 Encapsulation and Inheritance
EXERCISES | Q I. 2. | Page 444
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×