Results 1 to 4 of 4

Thread: encapsulation

  1. #1
    Junior Member
    Join Date
    Dec 2007
    Answers
    2

    encapsulation

    How we hide the data in encapsulation?where we are using encapsulation in real life problem?


  2. #2
    Junior Member
    Join Date
    Dec 2007
    Answers
    5

    Hi :)

    Main Concept : Encapsulation is the Process of Grouping together information in to a single entity that reveals only the necessary information to the user.

    Assumption : You have a Fair Knowledge in OOPS Concpets.

    Solution :
    When you create a Class there will be
    Private members and Public members.
    The Private members are Hidden from the user. i.e. the user cannot access the value of the Private members.

    The Public members on the other hand can be changed by the user.

    So finally what i am saying is
    When you create an Object for such a class that i have described the Object will "Abstract" the Private members and "Allow" the Public Members. So an Object is well known to a single entity. So as you can deduce


  3. #3
    Junior Member
    Join Date
    Dec 2007
    Answers
    2

    Re: encapsulation

    simplest way to illustrate encapsulation is by the function call (and more specifically the library functions and classes but dnt go for thtfor nw.) while using any function only a call is required rather the exact detail of how it is doing wht it is supposed to do.

    ex. in real life is driving a car. not everybody is aware of the thing tht how all the gears, brakes etc. doing their functions but we can still use them.


  4. #4
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: encapsulation

    The ability to provide users with a well-defined interface to a set of functions in a way which hides their internal workings. In object-oriented programming, the technique of keeping together data structures and the methods (procedures) which act on them.
    Well encapsulated objects act as a "black box" for other parts of the program which interact with it. They provide a service, but the calling objects do not need to know the details how the service is accomplished.

    In electronics, a resistor is an example of a well encapsulated object. It provides a particular service (so many Ohms of resistance) and you can plug it into a circuit and get the expected behavior. You don't need to know how the resistance is accomplished, you just depend on the resistor to do its job. If you later decide to replace this resistor with one of another value, or by another manufacturer, you don't have to rewire the circuit — you just pop the old resistor out and plug in a new one. If you chose the right component, the light bulb lights, and the buzzer sounds. Of course, if you choose wrong, you burn your entire house to the ground and nullify your homeowners insurance.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact