Tuesday 3 April 2012

What is encapsulation?


  1. It is the fundamental principle concept of oops.
  2. It hides the data from outside the world.
  3. You can also say that it is the process of hiding internal data from outside the world.
  4. It gives maintainability, flexibility and extensibility to our code.
  5. It gives the ability to hide the data and method fro m out side the world and only expose data and method that are required.
  6. it also hide the information from the object.
Example:

      Class Employee
     {
      private int _employeeId;
      private  double _salary;
     public int SetEmployeeId(int EmpId)
       {
           _employeeId=EmpId;
       }
     public int GetEmployeeId()
     {
       return _employeeId;
     }
     public double SetEmployeeSalary(double Salary)
       {

           _salary=Salary;
       }
     public int GetEmployeeSalary()
     {
       return _salary;
     }

No comments:

Post a Comment

Note: only a member of this blog may post a comment.