Help coderanch get a
new server
by contributing to the fundraiser
  • 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

Query about the object definition...

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello.. my question is about the object definition given in the SCJP 5 book by Kathy Sierra. The book says "at runtime when the JVM encounters the new keyword, it will use the appropriate class to make an object, which is an instance of that class. That object will have its own state, and access to all of the behaviors defined by its class. "

Now my question is related to the last sentence of the above definition.How can an object access private behavior of its class when it is instantiated in another class.

I am a confused.. please help soon....
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

As the definition says, object is an instance of that class so the created object contains all the private behavior of its own class, therefor does not matter when the object is defined. Think the object as a shell with all the classes behavior.

Hope to help!
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As the Question said... the properties of the class are instantiated in the newly created object.
they are not created but are inherited to the object...i.e., the newly created object will also have the same properties (that the class has).....

what you should get yourself clarified is that the newly born object is inheriting the qualities.... and that even the private properties of its class can be inherited but not attributed directly or say accessed...ok...
properties are inherited but not accessed.. they can be referred but not accessed from elsewhere...


hope that i cleared you query...if any clarifications...send me an email....ok
bye
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The property is specific to the class. It does not matter where you instantiate a class, it will still be able to use properties that belongs to it. Imagine if some one said you cannot use your arm if you are born in Germany.
 
Get me the mayor's office! I need to tell him about this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic