Data Hiding-:
Outside person can't access our internal data directly or our internal data should not go directly this Oops feature is data hiding.
After validation or authentication outside person can access internal data.
Exam. 1-: After providing proper username and password we can able to access our Gmail inbox information.
2-: Even though we are a valid customer of the bank. We can able to access our account information.
By declaring data member(variable) as private. We can achieve data hiding.
Exam. -: public class Account {
private double balance;
public double getbalance(){
//validation
return balance;
}
Advantage-:
The main advantage of data hiding is security.
Note-: It's highly recommended to declare data member(variable) as private.
2-: Even though we are a valid customer of the bank. We can able to access our account information.
By declaring data member(variable) as private. We can achieve data hiding.
Exam. -: public class Account {
private double balance;
public double getbalance(){
//validation
return balance;
}
Advantage-:
The main advantage of data hiding is security.
Note-: It's highly recommended to declare data member(variable) as private.