Geeks Talk

Prepare for your Next Interview




achieve Encapsulation in Java

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]...


Go Back   Geeks Talk > Software Development > Java

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 12-27-2006
Expert Member
 
Join Date: Oct 2006
Posts: 690
Thanks: 0
Thanked 49 Times in 41 Posts
JobHelper is on a distinguished road
achieve Encapsulation in Java

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

NOTE : [This question was asked by Srivani]
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-27-2006
Expert Member
 
Join Date: Sep 2006
Location: Bengalooru (Formerly called Bangalore), India
Posts: 486
Thanks: 2
Thanked 28 Times in 27 Posts
kalayama is on a distinguished road
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!"
Reply With Quote
  #3 (permalink)  
Old 08-22-2008
Junior Member
 
Join Date: Aug 2008
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
sjava.438 is on a distinguished road
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.
Reply With Quote
  #4 (permalink)  
Old 09-05-2008
Junior Member
 
Join Date: Jun 2007
Location: India
Posts: 20
Thanks: 0
Thanked 6 Times in 4 Posts
deeptiagrawal is on a distinguished road
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.
Reply With Quote
Reply

  Geeks Talk > Software Development > Java


Thread Tools
Display Modes


Similar Threads

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


All times are GMT -4. The time now is 05:24 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved