wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Difference between Object and Instance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

Difference between Object and Instance

Oceana Wickramasinghe
Ranch Hand

Joined: Mar 02, 2011
Posts: 77
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
Marshal

Joined: Mar 22, 2005
Posts: 41087
    
  43
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.


Ping & DNS - my free Android networking tools app
Oceana Wickramasinghe
Ranch Hand

Joined: Mar 02, 2011
Posts: 77
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
Marshal

Joined: Mar 22, 2005
Posts: 41087
    
  43
What I was trying to say was that there is no difference:

object = instance of a class
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

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.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
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

Joined: Aug 31, 2004
Posts: 11343

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


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3064
    
  33

Exactly similar question- http://www.coderanch.com/t/529242/java-programmer-SCJP/certification/Object-vs-Instance

Mohamed Sanaulla | My Blog
Nitesh Nandwana
Ranch Hand

Joined: Jun 07, 2011
Posts: 115

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

Joined: Jun 07, 2011
Posts: 115

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

Joined: Sep 08, 2007
Posts: 3064
    
  33

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

Joined: Jun 07, 2011
Posts: 115

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

Joined: Feb 12, 2011
Posts: 104

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

Joined: Jun 10, 2011
Posts: 207

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.

Piyush
Nitesh Nandwana
Ranch Hand

Joined: Jun 07, 2011
Posts: 115

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

Joined: Jun 07, 2011
Posts: 115

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

Joined: Sep 08, 2007
Posts: 3064
    
  33

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

Joined: Jun 07, 2011
Posts: 115

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

Joined: Mar 23, 2011
Posts: 30
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

Joined: Aug 16, 2005
Posts: 14074
    
  16

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between Object and Instance
 
Similar Threads
Difference between an Object and Instance.
Object question
object and instance
Related to Object
object Vs instance