wood burning stoves 2.0*
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


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 "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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Accessing private variables?
 
Similar Threads
JavaRanch question #208: private variable
objects parameters
private instance variables
accessing private variable of another object of same class
Can one object access the private variable of another object of the same class?