• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Objects themselves do not have

 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Objects themselves do not have any accessibility modifiers, only the object references do.

please explain the above.....
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can of course not gain access to the objects directly, only through references like,
private MyClass myObject;
protected YourClass yourObject;
etc.
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well objects are like persons in your class and access modifiers are like some specialties to the properties of objects. Say, take a name having # of vowels etc but person being an object itself, it may not possess these.

Of course, how do you get access to a person? Through his roll number in a class --- nothing but a reference (more like a pointer) that knows how to reach an object!

Now when it comes to 'access modifiers' -- a means to control the access, references are also members of a class in which it is declared. so they are very well eligible to hold those.

The example what Campbell gave explains you very clearly.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bert Bates and Kathy Sierra have come up with what I think is a pretty good analogy. Think of the object as a TV, and a reference as a remote control. you never touch the TV itself, only the remote. you use that to access the functions of the TV.
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, of course! Thank you fred!

That's one of the beautiful and undeniable examples!
[ April 10, 2008: Message edited by: Raghavan Muthu ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic