aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Accessing private variables? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Accessing private variables?" Watch "Accessing private variables?" New topic
Author

Accessing private variables?

d jones
Ranch Hand

Joined: Mar 13, 2006
Posts: 76
Hi,

I came across the following question in the Java Roundup rules quiz and I was very surprised with the answer.

Can one object access the private variable of another object of the same class?
Answer: Yes
Explanation: Private means private to the class not private to the object. So two objects of the same class could access each other's private data.

Could somebody please explain this to me? I don't understand!

Many Thanks
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

See this thread.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing private variables?