SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
Originally posted by adeel ansari:
no i think there is a difference.
have a look
here "a" is the object of class A, but the instance of class B.

Originally posted by michelle anderson:
an instance of a class is an object.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Originally posted by Abdulla Mamuwala:
There is a good explanation for the above question at the following URL,
TheServerSide.com
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Originally posted by Stan James:
Daniel, is talking about instances of relationships (and other things that are not classes) common anywhere? I can see it would be useful in the UML meta-model, but it's not something I've ever said out loud.
An object is an instance of a class. (makes sense)
An instance is an object of a class. (doesn't make sense)
A class is a collection of methods and the number and types of data over which those methods can operate. An object is a collection of methods and a set of actual data (the types and number of which are specified by the class of that object) over which those methods operate. The term instance expresses the relationship between such an object and its class.
or
or
or even worse
Originally posted by sever oon:
I would posit that the term "instance" as in the case of classes and objects is a different meaning altogether than "instance" in terms of everyday speech, as in "example of".
from http://whatis.techtarget.com/definition/0,,sid9_gci212355,00.html:
In programming, instantiation is the creation of a real instance or particular realization of an abstraction or template such as a class of objects or a computer process.
Originally posted by Roshan Lal:
What mentioned above is not quite right. An instance of a subclass is also an instance of its parent class. So the object/instance, variable "a" refers to is both an instance of B and A. However since "a" is given the type "A", it can only access behaviour of "A" from the created instance.
Originally posted by adeel ansari:
A a = null;
"a" is an object of class A.
now,
a = new B();
"a" is still an object of class A. but can be said the instance of both.
Originally posted by adeel ansari:
it can be refer as instance of both but we cant say that "a" is the object of class B. assume this.
Class A a = null;
"a" is an object of class A.
now,
a = new B();
"a" is still an object of class A. but can be said the instance of both.
>>> NO. This distinction is very important to understand.
"a" is only a variable which may point to an object of type A or subtype of A.
what you people say? and i think after this much discussion it is no more a beginner question may be some beginner got fever after reading it all.
>> Yes, probably should move to intermediate forum.
[ September 15, 2004: Message edited by: adeel ansari ]
[ September 15, 2004: Message edited by: adeel ansari ]
| Don't get me started about those stupid light bulbs. |