This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
What is the differance Between Object & Instance. Actually I think Object is Logical thing & instance is physical thing. Also when we create instance, at that time actual memory allocation is happens. So is any other differance in between these? Is my thinking is true?
In general Java discussions an object means same as an instance. No object is not a logical thing when creating object actual memory allocations happen.
If you are thinking about common textbook terminology, a class is logical representation and an object or an instance is where the memory allocation will happen.
Also while discusing Java, when by "object" you mean an object of class try to use all lower case letters. "Object" with first capital 'O' refers to the "class java.lang.Object" which is parent of all Java classes.
Pritam Barhate<br />A magic combination of <b>Code</b> & <b>Fire</b> : <a href="http://www.jroller.org/page/codefire/Weblog" target="_blank" rel="nofollow">codefire</a><br />----------------------------------- <br />My Open Source Projects:<br /><a href="https://acemdi.dev.java.net/" target="_blank" rel="nofollow">AceMDI</a>: A easy, yet powerful MDI framework that manages windows as Tabs.
Joined: Oct 07, 2004
Thanks for replying me. I understand from this that in JAVA object & instance are same
I was taught "an object is a runtime instance of a class". For all practical purposes I have always used object and instance interchangeably, personally I don't think it's worth too much thinking time.
I'm not convinced that what Sai says above is necessarily correct...
Vector v; --> v is the instance here.
[ November 29, 2004: Message edited by: Ben Wood ]
Vector v; --> v is the instance here. (Memory is not allocated)
v is not an instance -- it is an uninitialized reference. "Instance" indicates that an object has been created. "Object" implies the same this. "Class" indicates a template for building objects (unless you are talking about the "Class Object", which is an instance of the java.lang.Class class...). "Reference" is a variable in code -- not the object itself, but rather how we work with the objects. When an object has no refences to it, it is available for garbage collection. (There are other times as well, but this definition will suffice.)
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
It's probably worth pointing out that Object (with a capital Oh) is different from an object. Object is a class that is the ultimate grand-daddy of all classes while an object is an instance of any class. (So you are correct, "instance" and "object" are the same thing in Java -- and in most Object Oriented Programming Languages from my experience.)