Computer Science, asked by Anonymous, 1 year ago

What's Encapsulation? Explain in detail

Answers

Answered by kvnmurty
3
Encapsulation is to model a real life situation in to a computer program.

     Encapsulation method is used by Object oriented languages.  The real life problem to be solved is modeled into objects, properties and methods.  It is done in a manner to provide a secure and shared programming environment, where one's program is used by others in the project or by clients.

     Encapsulation is to create object classes for different types of  data we find in real life.  Then we identify the properties of the class.  We identify then the private properties and  public properties, which are accessible to users of the class.  The private properties are not directly visible to public users.  They can only be modified by  functions or methods provided by owner.

   The methods or functions of an object class are the functions or procedures that access (retrieve) the variables (properties) of an object or class and modify them.

   This a structured way of putting essential data as properties, and writing secure and safe methods to access them and modify them is encapsulation.  It is most important point of object oriented programming and DESIGN of  OOPS programs.

     The main use is to reduce corruption of data, introduction of bugs by a programmer, due to improper  handling of code.

example:
   A  student.

class  student  {
       private properties
         name  :  string of characters ;
          date of birth :  integer ;
      public properties :

     private methods:
           setName ( name ) ;
           setDOB ( date of birth)

     public methods :
           getName () ;
           getAge();

}



kvnmurty: click on thank you and select best answer
Anonymous: there is no any other answer yet so...........................
kvnmurty: ok
Answered by Aditi1234srivastava
3

Answer: Encapsulation is the technique of binding both data and functions together to keep them safe from unauthorised access and misuse it ensures that a user cannot access the data without proper authorisation it also ensure that a user can have access only to those functions for which he is authorised by other function remain unaffected

Similar questions