• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

serialization..

 
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can anyone explain me what exactly object state means?

i read that only instance variables are part of object state and not even instance methods(from whizlab).
i thought methods also part of object state.

please someone clear this...

Thanks
Preetha
 
Ranch Hand
Posts: 952
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, no only instance variable are object's state.

Instance methods are shared between all objects of a class.
While instance variable are provided different memory for all objects.
 
Ranch Hand
Posts: 1032
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's a good point (only instance variables are part of an object's state.)
Static references are not considered part of an object-specific state, even though they represent some sort of state. What thing do they represent the state of? The class. And like Punit mentioned about instance methods being shared by all objects of the class, the same happens with static references (and methods, of course.)

Above, when I say object-specific state, what I mean is that every object is affected by the state of the class (represented by the values of static references,) but this is not state specific to the object itself, which only encompasses the state of instance references.
[ December 19, 2008: Message edited by: Ruben Soto ]
 
Preethi Dev
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
still i am not clear. could someone please explain me with an example...

thanks
Preeth
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Every class describes what an object knows and what an object does.
What Object knows is Instance variable(State) and What object does is Method(Behavior)

For example:
Consider this;

class Animal
{
Instance variables/State: like weight, location, color etc.
Methods/Behavior: like eat(),roam()and so on.
}

Hope this may help you in understanding better.
 
Preethi Dev
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rajkumar, it's clear now.

Preparing for Scjp5
Preetha
 
To get a wish, you need a genie. To get a genie, you need a lamp. To get a lamp, you need a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic