OOPS CONCEPT
Data hiding
The outside person can't access our internal data directly or our internal data should not go directly to the outside person .this oops feature is called data hiding,
After validation or identification, we can access our internal data.
Example-:
1.After providing a proper username and password we can able to access our Gmail inbox
2.Even though we are valid customers of the bank. we can access our account information, but we can't access others' account pieces of information.
By declaring member (variable) as private. we can achieve data hiding
public class Account{
private double balance;
public double getBalance(){
// validation
return balance;
}
}
Highly recommended to declare data member (variable) as private.
0 Comments