Javatpoint Logo

Difference between Instance and Object ?

By: raju0564@gmail.com On: Mon Jul 22 06:26:48 EDT 2013     Question Reputation16 Answer Reputation0 Quiz Belt Series Points0  16Blank User
Difference between Instance and Object ?
Difference between "equals" and "==" methods ? with suitable examples
Up0Down

 
They are the same thing in most object-oriented languages. "Instance of a class" is just how the term "object" is defined.


Every object is an instance of a class. And every instance of a class is an object. You can basically interchange these.

----------

you have 5 apples in your basket. Each of those apples is an object of type Apple, which has some characteristics (i.e. big, round, grows on trees).

In programming terms, you can have a class called Apple, which has variables size:big, shape:round, habitat:grows on trees. To have 5 apples in your basket, you need to instantiate 5 apples. Apple apple1, Apple apple2, Apple apple3 etc....

Alternatively: Objects are the definitions of something, instances are the physical things.

Does this make sense?
Image Created0Down

By: malikravi908@gmail.com On: Mon Jul 22 07:39:48 EDT 2013 Question Reputation0 Answer Reputation392 Belt Series Points0 392User Image
Are You Satisfied :6Yes4No
 
can i say object=instance ?Image Created0Down

By: raju0564@gmail.com On: Mon Jul 22 07:59:31 EDT 2013 Question Reputation16 Answer Reputation0 Belt Series Points0 16User Image
Are You Satisfied :5Yes1No
 
instance means allocating the memory space by the jvm and object means initializing the variables inside that instance. But most the people says like instance is object and object is instance.Image Created0Down

By: pnsmgl@gmail.com On: Tue Jul 23 01:56:55 EDT 2013 Question Reputation20 Answer Reputation4 Belt Series Points0 24User Image
Are You Satisfied :2Yes1No
 
Class is Data Type,You use this type to create object.

Instance is Logical but object is Physical means occupies some memory.

We can create an instance for abstract class as well as for interface, but we cannot create an
object for those.

Object is instance of class and instance means representative of class i.e object.

Instance refers to Reference of an object.

Object is actually pointing to memory address of that instance.

You can?t pass instance over the layers but you can pass the object over the layers

You can?t store an instance but you can store an object

A single object can have more than one instance.

Instance will have the both class definition and the object definition where as in object it will have only the object definition.
Image Created0Down

By: aasifali1992@gmail.com On: Sun Aug 11 13:37:44 EDT 2013 Question Reputation0 Answer Reputation5 Belt Series Points0 5User Image
Are You Satisfied :1Yes0No
 
Image Created0Down

By: gagank_w@rediffmail.com On: Tue Aug 01 00:08:23 IST 2017 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No