English

How Are Private Members of a Class Different from Public Members ? - Computer Applications

Advertisements
Advertisements

Question

How are private members of a class different from public members?

One Line Answer
Short Answer

Solution 1

The scope of the private members is within the class whereas the scope of the public members is global.

shaalaa.com

Solution 2

  1. Private:
    1. A private access specifier restricts access to a variable or method within a class.
    2. Private elements are not shared with other classes during inheritance.
  2. Public:
    1. A public specifier indicates that a variable or method is directly accessible from all classes.
    2. During inheritance, one class shares public elements with another. 
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 384]

APPEARS IN

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

Englishहिंदीमराठी


      Forgot password?
Use app×