• Post Reply Bookmark Topic Watch Topic
  • New Topic

state of an object  RSS feed

 
Rama SManian
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends!!

This is something that stumped me. When we create an object of a class say A

class A{

}

This class is an empty class. When i create an object of this class what would be in its state ?
( no variables for state and no methods for behavior). Since java.lang.object will be called , its methods will be a part of the object behavior.

So is anything added in a java object's state by default by the JVM..

any pointers..article links will be appreciated.

Thanks
RKS
 
Arto Pastinen
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

It is INSTANCE from class A, so it is one state.

If you have two instance, and you compare them (foo == bar) it is false, because they are not same instances.

Artsi
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your object would inherit all the state & behavior of the Class class. That sounds a bit like double-talk, but look at the JavaDoc for Class. It knows quite a bit about itself - its methods and variables for example. Of course your example has none, but at least it knows that!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!