Re: a very tricky question...
- From: Lew <lew@xxxxxxxxxxxxx>
- Date: Mon, 23 Jun 2008 09:23:42 -0400
birensubudhi@xxxxxxxxx wrote:
In java [sic] in object only the nonstatic members are present & the static
members donot reside in the object but we are accessing static members
using object reference technique.
The static member still has to reside somewhere. It isn't in limbo. Static members reside in the class itself. The class is like an object itself - it has member references and member methods, those marked 'static' in the class definition.
since the static member do not reside in the object
There is no "the object". Static members reside in another object, the one representing the class itself.
then how we are accessing it using object reference...
Two different things, objects and references.
Objects referred to by instance members don't "reside in the object" either. A reference lives inside an object, either in an instance object or the class itself. The reference points to another object or to 'null'. The referenced object doesn't "reside in" anything but heap, conceptually.
Classes and instances don't have member objects. They have member references. References point to objects. Objects don't "reside in" other objects. References do, sometimes, but not necessarily in instance objects. The place from which a reference points and the place to which it points are two different things.
--
Lew
.
- References:
- a very tricky question...
- From: birensubudhi@xxxxxxxxx
- a very tricky question...
- Prev by Date: a very tricky question...
- Next by Date: Re: How to combine characters
- Previous by thread: a very tricky question...
- Next by thread: Re: a very tricky question...
- Index(es):
Relevant Pages
|