Encapsulation:[Bundling of fields[variables] and method inside a single class]
adv: It prevents outer classes from accessing and changing the fields of a class
getter & setter methods in java[POJO class]==>plain old java objects
gettermethod–>there must be a returntype other than void
class Bank
{
private int minimumbalance=2500;
public int getminimumBalance()//getter method
{
return minimumbalance;
}
}
class Accountholder
{
public static void main(String args[])
{
Bank bb=new Bank();
int min=bb.getminimumBalance();
System.out.println(min);//2500
}}