Encapsulation



Encapsulation is mean Hiding & wrapping your data.

but, why it's need to hiding & wrapping data.so that is the one question. in OOP concept the first main concept of encapsulation. and what is use is.
suppose, i am withdrawing 100 rs. from my saving account.
here is one account holder and bank between transaction of 100 rs.
so that, encapsulation is need. 


ex,

class c{
private int rupees;//when private declare variable that encapsulate your data...
public void tran(int x){
rupees = x;
System.out.println(rupees);
}
}
public class demo {
public static void main(String args[]){
c d = new c();
//d.rupees = 100;//and directly not assign or change values to private variable
d.tran(1000);
}
}


*****************************************************



Comments