Encapsulation

in Hindi - Encapsulation



not yet

Source Code :

RUNpublic class Employee{
 
 private int emp_id;
 private String emp_name;
 private int emp_salary;
 
 
 public void setid(int newid){
 emp_id = newid;
 
 }
 
 public void setname(String newname){
 emp_name = newname;
 
 }
 
 public void setsalary(int newsalary){
 emp_salary = newsalary;
 
 }
 
 public int getid(){
 return emp_id;
 }
 
 public String getname(){
 return emp_name;
 }
 
 public int getsalary(){
 return emp_salary;
 }
 
 public static void main(String args[]){
 Employee emp = new Employee();
 emp.setid(1);
 emp.setname("UD");
 emp.setsalary(20000);
 System.out.println("Employee id is "+emp.getid());
 System.out.println("Employee name is "+emp.getname());
 System.out.println("Employee salary is "+emp.getsalary());
 }
}