This gives rise to a problem: Data Theft.
Because the Data and Methods of one program can be accessed by another, there are chances that others might steal your data, or your code.
To overcome this problem, we have been provided with what are called 'Access Modifiers'. Using Access Modifiers, you can specify what parts of your programs can be accessed by other programs.
The 3 most-used modifiers are 'public', 'private', and no-modifier.
1. 'public' members(data or methods) can be accessed from ANYWHERE by ANYONE.
2. 'private' members can be accessed ONLY by other members of the SAME class.
3. no modifier: If you do not specify a modifier, it is taken to be 'friendly' by default, ie, it can be accessed by all classes in the same package.
See this link to get a complete understanding.
No comments:
Post a Comment