What is the difference between an object and an instance? And give me a real time example to differentiate these two?

Questions by Beena   answers by Beena

Showing Answers 1 - 21 of 21 Answers

rajesh

  • Sep 18th, 2005
 

the  key  diff between  an  object and  an instance  is  that  in  real  time  synanyo is  that--------i  think  u  know  about  "blueprint" (plans)  which  is  used for  house construction.think    this  as  an a "instance"  and  implementation of   this  plan  is  nothing  but  "object"  ok  bye

  Was this answer useful?  Yes

S.Naveen Kumar

  • Oct 26th, 2005
 

An Object May not have a class defination eg int a[] where a is an array

An Instance Should have a class defination

eg  MyClass my=new MyClass();

my is an instance

gj

  • Feb 18th, 2007
 

consider a class A . When you do  " new A() " , you have created an object since it has actual memory allocated in the heap.

A a = new A(); , here 'a' is an instance of the object that was created using "new A()"

  Was this answer useful?  Yes

Rajesh G

  • Aug 3rd, 2007
 


Object : Memory allocated by the JVM in Heap is nothing but an object.

Instance: If that memory is assigned to a class definition then it is called an Instance.


Rajesh G

sampra

  • Mar 6th, 2008
 

both are same the best example is if fruit is a class then its following the class rule if fruit is a class then mango is the one of object  instanc and object are same jst both are same  only name is different

  Was this answer useful?  Yes

object and instance both mean same in java world.

probably you wanted to ask whats the diff between  class and instance.

if thats the case

classes dont  exist , its the instances that exist in memory.

vehicle is a class , honda city is an instance.

when you try to instantiate , JVM takes class(blue print) and creates instance according to it on Heap.

An object is part of a process/thread which demands processor time through the JVM.

The act of creating the object from a class is called instantiation.

In literary sense an instance is existance/occurrence of an object.

In this case a duplicate copy(instance) of an object is still the same object.

  Was this answer useful?  Yes

Sarje

  • Aug 15th, 2009
 

object and instance both are same
I think you want know the difference between reference and object.
If so then
reference of any class type is a variable that can hold the reference(more or less we can say address) of that class's object. For example
String str;
here str is a reference variable of the String class's object means it can hold reference of the String class.
str = new String("Ram");
Now here new creates the instance(object) of the String and returns its reference to the str.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions