Monday, June 27, 2016

Data hiding

Data hiding is the most important concepts in OOPs oriented programming. Java security is also depend on Data Hiding concepts.


Its just way to protect your data from the outside world. meanwhile outside person can not access our data its mean our internal data should not go out directly this oops feature is called data hiding.

after validation or authentication of outside world can access our internal data.

if we have a class having public data field or methods. So data member can be accessed by outside person. here, there is no security for internal data.

for hiding our data from outside person , we need to declare our data as private or protected.

 such an example :  If we have an account in a bank. but we are not able to access our account information for accessing our information regarding account, So first bank will provide login authentication your user name and password. then you can check your account information.


        public class Account {
                             private double balance;
                             public double getBalance()
                             {
                               // validation
                                return balance.
                              }
                            }


Advantage of Hiding data for security. So its highly recommended to declare data member variable as private.


<<         >>

No comments: