English

Which of the following statements is the most appropriate for the private members? - Computer Applications

Advertisements
Advertisements

Question

Which of the following statements is the most appropriate for the private members? 

Options

  • They are visible out of the class in which they are defined.

  • They can be used in the sub-classes.

  • They are only visible in the class in which they are declared.

  • None of the above. 

MCQ

Solution

They are only visible in the class in which they are declared.

Explanation:

Private is a keyword in programming languages that serves as an access modifier. When you declare an object as private, it can only be accessible within the class. We can, however, use the getter and setter methods to access private data. This keyword can be applied to attributes, methods, and constructors. 

shaalaa.com
  Is there an error in this question or solution?
Chapter 6: Class as the Basis of all Computation (Objects and Classes) - EXERCISES [Page 382]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 6 Class as the Basis of all Computation (Objects and Classes)
EXERCISES | Q I. 4. | Page 382
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×