Win a copy of The Java Performance Companion this week in the Performance forum!
    Bookmark Topic Watch Topic
  • New Topic

Difference between Object and Instance

 
Oceana Wickramasinghe
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hey guys, i posted this question to another forum but i didnt get a satisfying answer. What is the exact difference between Object and Instance. Different people and websites offer different explanations and im so confused. What does oracle say about this? and what is your theory? Thanks in advance
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Likes 2
  • Mark post as helpful
  • send pies
  • Report post to moderator
An object is an instance of a class. How's that for confusion? :-)

To elaborate a bit more: A class is something lifeless - a .class file that has the potential of doing something - what that is is described in the javadocs of that class. But to make it into an object, you need to call "new MySuperClass()" - which will hand you a reference to the object; now you have something that's alive, and on which you can invoke methods.

So, all objects are instances of some class - which makes the original question a bit pointless. The difference you need to understand is between classes and objects.
 
Oceana Wickramasinghe
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Report post to moderator
sorry but i do understand the difference between Class and Object. What i need to know is the difference between Object and Instance.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Report post to moderator
What I was trying to say was that there is no difference:

object = instance of a class
 
Maneesh Godbole
Saloon Keeper
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Report post to moderator
Imagine a mould for making say candles. You pour the molten wax in it, let it cool and out comes the candle. You do it 100 times and end up with 100 candles.
The mould is the Class. All the candles you made from the mould are the objects or instances of that class.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Report post to moderator
There are no differences between an object and an instance. They are the same thing. In other words, in object-oriented terminology, the words "object" and "instance" have the same meaning and authors can use them interchangeably.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Report post to moderator
Every object is an instance of a class. And every instance of a class is an object. You can basically interchange these.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Report post to moderator
Exactly similar question- http://www.coderanch.com/t/529242/java-programmer-SCJP/certification/Object-vs-Instance
 
Nitesh Nandwana
Ranch Hand
Posts: 115
Firefox Browser Java Notepad
  • Mark post as helpful
  • send pies
  • Report post to moderator
Ulf Dittmer wrote:What I was trying to say was that there is no difference:

object = instance of a class


you mean authors call it sometime instance and sometime object without any reason then what is meaning of having two name of same thing.I've doubt that there should be any reason .why don't we've two name of class so it's depend on my mood so some time i call it class and sometime anything.

I'm requesting everyone to give answer of my question please. for your efforts in advance.
 
Nitesh Nandwana
Ranch Hand
Posts: 115
Firefox Browser Java Notepad
  • Mark post as helpful
  • send pies
  • Report post to moderator
Jimmy Clark wrote:There are no differences between an object and an instance. They are the same thing. In other words, in object-oriented terminology, the words "object" and "instance" have the same meaning and authors can use them interchangeably.

you mean authors call it sometime instance and sometime object without any reason then what is meaning of having two name of same thing.I've doubt that there should be any reason .why don't we've two name of class so it's depend on my mood so some time i call it class and sometime anything.

I'm requesting everyone to give answer of my question please. for your efforts in advance.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Report post to moderator
Nitesh Nandwana wrote:
Ulf Dittmer wrote:What I was trying to say was that there is no difference:

object = instance of a class


I'm requesting everyone to give answer of my question please. for your efforts in advance.

I dont know what more answers you are expecting.
 
Nitesh Nandwana
Ranch Hand
Posts: 115
Firefox Browser Java Notepad
  • Mark post as helpful
  • send pies
  • Report post to moderator
marc weber wrote:Every object is an instance of a class. And every instance of a class is an object. You can basically interchange these.


you mean authors call it sometime instance and sometime object without any reason then what is meaning of having two name of same thing.I've doubt that there should be any reason .why don't we've two name of class so it's depend on my mood so some time i call it class and sometime anything.

I'm requesting everyone to give answer of my question please. for your efforts in advance.
 
Pavan Kumar Dittakavi
Ranch Hand
Posts: 106
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Report post to moderator
I feel that generally we used to go by the name 'object' in c++ programming language. That's what most of the books refer to them!

But, JAVA authors(or Sun itself) came up with this word 'instance' .

So, on the whole these words are being used interchangeably!.

Thanks,
Pavan.
 
Piyush Joshi
Ranch Hand
Posts: 207
Eclipse IDE Firefox Browser jQuery
  • Likes 1
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi Nitesh, Firstly Please don't post the same question again and again.
Nitesh Nandwana wrote:what is meaning of having two name of same thing.

Why can't someone express something in more than one way, using more than one names?
Nitesh Nandwana wrote:why don't we've two name of class so it's depend on my mood so some time i call it class and sometime anything.

You can make up a name for class and use it depending on your mood. But will the idea or notion of a class change?

The thing that I want to say is that please dont be bothered about names, get the idea or concept.
 
Nitesh Nandwana
Ranch Hand
Posts: 115
Firefox Browser Java Notepad
  • Mark post as helpful
  • send pies
  • Report post to moderator
Mohamed Sanaulla wrote:
Nitesh Nandwana wrote:
Ulf Dittmer wrote:What I was trying to say was that there is no difference:

object = instance of a class


I'm requesting everyone to give answer of my question please. for your efforts in advance.

I dont know what more answers you are expecting.


dear sanaulla I m looking here for solid answer and you know solid means that what is need of having two name object and instance and if there is no reason then why don't we make a great history in java by naming another name of class ? when object has two name then why it's dady has one name ? we should do something about it.
 
Nitesh Nandwana
Ranch Hand
Posts: 115
Firefox Browser Java Notepad
  • Mark post as helpful
  • send pies
  • Report post to moderator
Piyush Joshi wrote:Hi Nitesh, Firstly Please don't post the same question again and again.
Nitesh Nandwana wrote:what is meaning of having two name of same thing.

Why can't someone express something in more than one way, using more than one names?
Nitesh Nandwana wrote:why don't we've two name of class so it's depend on my mood so some time i call it class and sometime anything.

You can make up a name for class and use it depending on your mood. But will the idea or notion of a class change?

The thing that I want to say is that please dont be bothered about names, get the idea or concept.


Dear joshi ji, leave idea and concept beside first thing there shouldn't be any terminology confusion for beginner .if it is then it should be clear never mind even it is small thing,and you can post any question any no of times.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Report post to moderator
Nitesh Nandwana wrote:
Dear joshi ji, leave idea and concept beside first thing there shouldn't be any terminology confusion for beginner .if it is then it should be clear never mind even it is small thing,and you can post any question any no of times.

You need not post the same query multiple times with a different quote.
I dont know why you are so much concerned with the terminology. You just relate that both mean the same and you are good to go. There are lot of other things in Java which you have to learn and which are much more important than just- Object or instance.
I can suggest another name for Class- Template.
 
Nitesh Nandwana
Ranch Hand
Posts: 115
Firefox Browser Java Notepad
  • Mark post as helpful
  • send pies
  • Report post to moderator
Mohamed Sanaulla wrote:
Nitesh Nandwana wrote:
Dear joshi ji, leave idea and concept beside first thing there shouldn't be any terminology confusion for beginner .if it is then it should be clear never mind even it is small thing,and you can post any question any no of times.

You need not post the same query multiple times with a different quote.
I dont know why you are so much concerned with the terminology. You just relate that both mean the same and you are good to go. There are lot of other things in Java which you have to learn and which are much more important than just- Object or instance.
I can suggest another name for Class- Template.


thank you sanaulla ji
 
jake dickens
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Report post to moderator
Think a object is like a remote for the tv you need that object to control but the instance is a copy of the object does that help?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15369
40
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
jake dickens wrote:Think a object is like a remote for the tv you need that object to control but the instance is a copy of the object does that help?

It's really simple: an object is an instance of some class.

A house is built according to a plan, the blueprint. The house is an object, and the house is also an instance of the blueprint.

Saying things like "the instance is a copy of the object" is confusing, I don't know exactly what you mean by it but I don't think it is correct. The word "object" and "instance" are just two words that refer to the same thing, there's nothing with copying going on.
 
    Bookmark Topic Watch Topic
  • New Topic