This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Private Variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Private Variables" Watch "Private Variables" New topic
Author

Private Variables

Puja Sinha
Greenhorn

Joined: May 25, 2011
Posts: 27
Can one object access a private variable of another object of the same class ?
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1447
    
    6

Do you mean something like this?


If yes, the answer should be yes, because access specifier is specific to class, not specific to an object of the class.


Swastik
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3064
    
  33

private variables can be accessed only with in the class where they are declared.
I would suggest you to write a small program to clear your queries. If you are still stuck you can post your code here and we can help you out. This way you can learn better and retain the concepts longer.


Mohamed Sanaulla | My Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Private Variables
 
Similar Threads
Question 80 from Java rules round up
private variable scope
when private is not so private
Object Accessibility
Private member access