• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

class members, instance members and object state

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just got the Kathy and Bert book and am reading like mad!!! Just want to clarify my doubts...

Class members - are static attributes and methods. They belong to the class and are created when the class is loaded. Primitives are initialized to default values and references are set to null if not explicitly initialized. All the instances of the class (objects) share one singe set of class members.

Instance members - are created when a class is instantiated or an object is created using the new keyword. Each Object has its own set of instance attributes. Primitives are initialized to default values and references are set to null if not explicitly initialized.

Please correct me if my understanding on the above concepts is wrong.

Kathy and Bert say - "... (pg 2) collectively, the values assigned to an object's instance variables makes up the object's state.

This means that Class variables do not define or impact an object's state. An object's state is totally and only dependent on its (instance) attributes?
[ July 10, 2006: Message edited by: Isuru Sampath ]
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Understanding Instance and Class Members
 
Isuru Sampath
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have been thinking on these for a while now...

An object's state is defined only by it's instance members, simply because the instance members hold data that belongs to the particulr object only. The class members are common to all the objects, so they do not help in defining an objects state. Clean and clear.

My question is can we say the same thing about a singleton class?

 
knowledge is the difference between drudgery and strategic action -- tiny ad
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic