Results 1 to 4 of 4

Thread: achieve Encapsulation in Java

  1. #1
    Expert Member
    Join Date
    Oct 2006
    Answers
    209

    achieve Encapsulation in Java

    How we can achieve Encapsulation in Java? (using any keywords or methods etc)

    NOTE : [This question was asked by Srivani]


  2. #2
    Expert Member
    Join Date
    Sep 2006
    Answers
    477

    Re: achieve Encapsulation in Java

    Simple. Use a class. (just like C++). Use specifiers like private and public to distinguish beween data to be hidden and revealed.

    (Correct me if I am wrong. I am a novice in Java)

    Cheers!
    Kalayama

    [COLOR="Blue"][SIZE="2"]"If you are not living on the edge of your life, you are wasting space"[/SIZE][/COLOR]

    Someone says "Impossible is nothing". The man next him says "Let me see you licking your elbow tip!"

  3. #3
    Junior Member
    Join Date
    Aug 2008
    Answers
    15

    Re: achieve Encapsulation in Java

    Hi
    take a class and define members (i.e variables and methods). class encapsulate members by controlling the access of the members. this controlling is handled by access specifiers.


  4. #4
    Junior Member
    Join Date
    Jun 2007
    Answers
    20

    Re: achieve Encapsulation in Java

    Define a class with all the data members declared as private so that they are not publically accessible to any other class and all the methods that works upon or uses these data members as public. In this way encapsulation is achieved in Java.


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