Prepare for your Next Interview
This is a discussion on achieve Encapsulation in Java within the Java forums, part of the Software Development category; How we can achieve Encapsulation in Java? (using any keywords or methods etc) NOTE : [This question was asked by Srivani]...
|
|||
|
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!" |
|
|||
|
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. |
|
|||
|
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.
|
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Achieve Scalability in Program | RyanJames | C and C++ | 3 | 12-15-2006 02:08 PM |
| How to achieve this | joel | Windows | 1 | 09-13-2006 12:32 PM |
| How to achieve system performance | timmy | Unix/Linux | 2 | 08-31-2006 12:57 PM |
| Want to achieve Double spaced output | christia | Unix/Linux | 0 | 07-31-2006 11:21 AM |
| To achieve Designs in PHP | scott | PHP | 3 | 07-13-2006 11:11 PM |