Java- Data Hiding/ Chapter -1 / OOP's Concept



Data Hiding

Java Data Hiding:-


In Java Data Hiding means outside person cannot access our internal data directly.
                                                or
Our internal data shouldn't go out directly this OOP's feature is called as "Data Hiding".

After validation or identification outside person can access our internal data.  

example 1: -After entering valid username and password we can able to access our Gmail account information.

example 2: -Even though we are the valid customer of the bank, we can able to access our account information and we can't access other's account information.

               

                HOW WE CAN ACHIEVE DATA HIDING IN JAVA




Java- Data Hiding/ Chapter -1 / OOP's Concept

Data Hiding:-

Outside person cannot access our internal data directly.
                                    or
Our internal data shouldn't go out directly this OOP's feature is called as "Data Hiding".

After validation or identification outside person can access our internal data.  

example 1: -After entering valid username and password we can able to access our Gmail account information.

example 2: -Even though we are the valid customer of the bank, we can able to access our account information and we can't access other's account information.

                  HOW ACHIEVE DATA HIDING

Java- volatile modifier / Chapter -10 / Access Modifier




Java Volatile modifier


1." volatile" is a modifier applicable only for variable and we can't apply for methods & classes.

2.If a value of a variable keeps on changing by multiple threads then there may be a chance of data inconsistency problem.We can solve this problem by using "volatile modifier".

3.If a variable declared as volatile then for every thread JVM will create a separate local copy.



Java- volatile modifier / Chapter -10 / Access Modifier


  1. "volatile" is a modifier applicable only for variable and we can't apply for methods & classes.
  2. If a value of a variable keep on changing by multiple threads then there may be a chance of data inconsistency problem.We can solve this problem by using "volatile modifier".
  3. If a variable declared as volatile then for every thread JVM will create a separate local copy.

Java- transient modifier / Chapter -9 / Access Modifier


java transient modifier

Java transient modifier


1. transient is the modifier applicable only for the variable.

2. We can use the transient keyword in serialization context.

3. At the time of serialization if we don't want to save the value of a particular variable to meet security constraint then we should declare that variable as transient.

 


Java- transient modifier / Chapter -9 / Access Modifier


  1. transient is the modifier applicable only for the variable.
  2. We can use the transient keyword in serialization context.
  3. At the time of serialization if we don't want to save the value of a particular variable to meet security constraint then we should declare that variable as transient.

Java- native modifier / Chapter -8 / Access Modifier

java native modifier

java native modifier


1. "native" is a modifier applicable only for methods and we cannot apply anywhere else. 2. The methods which are implemented in non-java (C or C++) are called native methods. 3. The main objective of native modifier are:-



  • Improve performance of the system.

  • To achieve machine level or memory level communication.

  • To use already existing legacy (non-java) code.



Java- native modifier / Chapter -8 / Access Modifier



1. "native" is a modifier applicable only for methods and we cannot apply anywhere else.
2. The methods which are implemented in non-java (C or C++) are called native methods.
3. The main objective of native modifier are:-

  • Improve performance of the system.
  • To achieve machine level or memory level communication.
  • To use already existing legacy (non-java) code.

Java- synchronized modifier / Chapter -7/ Access Modifier


java synchronized modifier

 Java synchronized  modifier


1." synchronized" is a modifier applicable for methods and blocks but not for classes and variables.

2.If multiple threads are trying to operate simultaneously on the same java object then, there may be a chance of data inconsistency problem.This is called "Race Condition".We can overcome this problem by using synchronized keyword or modifier.


Java- synchronized modifier / Chapter -7/ Access Modifier

  1. synchronized is a modifier applicable for methods and blocks but not for classes and variables.
  2. If multiple threads are trying to operate simultaneously on the same java object then, there may be a chance of data inconsistency problem.This is called "Race Condition".We can overcome this problem by using synchronized keyword or modifier.
  3. If a method or block declared as synchronized then at a time only one thread is allowed to execute that method or block on the given objects so that data inconsistency problem won't come.

Flipkart End Of Season Sale






© Copyright 2017 Javabychetan.blogspot.com