Differences between Object and Instance


There is a lot of discussions on this topic over the internet. Some of the people says both are same and some of other says both are different. Here I am planning to share my overall view on this topic. As per my knowledge both are looks same but different. Here are the some useful points:

  • 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.

Syntax of Object:

classname var=new classname();

But for instance creation it returns only a pointer refering to an object, syntax is :

classname varname;

 

Other Useful Links:

Difference between Abstract Class and Interface

What are the differences between EAR, JAR and WAR file?

Differences between callable statements, prepare statements, createstatements

Advertisements
About

I born in Good cultural place called India. My family is traditional family. We fallow all Indian traditions.

Tagged with: , , , , ,
Posted in JAVA
19 comments on “Differences between Object and Instance
  1. gopi says:

    hi
    mallik,

    this post is really good u r ideas of explanation is good
    it helps me a lot to understand the difference between intance and object

    regards,
    gopi

  2. MM.Atavulla says:

    oh!!!

    Mallik…

    Good ur ex-poser abt differences….

  3. […] What are the differences between object and instance? […]

  4. Subhranshu says:

    Thanks dear
    Its really good explanations.Thanks again

  5. Subhranshu says:

    Subhranshu :
    Thanks dear
    Its really a good explanation
    .Thanks again

  6. Piyush sharma says:

    very good explanation

  7. dasariuma48 says:

    Very Clear……………
    Thank You…

  8. Rohit says:

    it was a good explanation.

  9. Rohit Dabas says:

    many times i went and found the difference between the object and instance but no result .
    @malik -no confusion now .Instance is the reference variable to hold the reference id of object.
    very good explanation
    thanks

  10. varsha kotahri says:

    very nice explanation….
    very helpful

  11. arun says:

    Hi,Malik
    its good but little bit confuse.if you give one example of this it is more understandable .
    A single object can have more than one instance.how?

    instance means allocating the memory space by the jvm and object means initializing the variables inside that instance. is it correct or not?

  12. […] M. (2010) Differences between Object and Instance, Java Tutorials. Available at: http://malliktalksjava.in/2010/05/17/what-is-the-difference-bet-ween-object-and-instance/ (Accessed: 11 November […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 676 other followers

Calendar
May 2010
M T W T F S S
« Apr   Jun »
 12
3456789
10111213141516
17181920212223
24252627282930
31  
Mallikarjun Gunda

This is Mallikarjun Gunda, I am working as a software professional. Blogging is my Passion. This blog contains the posts on Java related technologies and programming languages. I am happy to share my knowledge through the blogs.

Blog Stats
  • 233,279 hits
IndiBlogger
malliktalksjava.wordpress.c...
70/100
All tags
AngularJS Apache Cassandra Arrays in Java Cassandra Cassandra Database Cassandra examples client stubs creating a java web service creating a web service using java difference between interface and abstract class Differences between SOAP and RESTfull webservices Display div as Overlay using JQuery download the spring basic application File directory Generating webservice client stubs Hibernate hibernate exceptions How to display over using JQuery how to generated web service client stubs in STS How to implement Spring basic application how to write singleton design pattern in java interface in java Java Java Arrays Java Example Programs Java examples Java interview questions java programs java project Java sample Programs Java Script JavaScript JavaServer Faces Java Sorting alogorithms Java Tutorials javatutorials Java Web services JDBC open shift openshift Overlay implementation using JQuery Overlay in JQuery POI API POI Examples public class public static void main Redhat OpenShift representational state transfer Restfull webservices sample programs in java Service-oriented architecture Singleton design pattern in java SOAP SOAP Webservices software Spring Framework Spring Interview Questions Spring MVC Spring MVC Example program Spring MVC sample Program Spring Sample Programs Spring Tutorials Struts technology Top Java Interview questions w3c dom Web service web service client Web Service Description Language webservices Web services writing singleton design pattern in Java WSDL Xml xml parsers