Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Difference between Object and Instance

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43028
76
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
What I was trying to say was that there is no difference:

object = instance of a class
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Exactly similar question- https://coderanch.com/t/529242/java-programmer-SCJP/certification/Object-vs-Instance
 
Ranch Hand
Posts: 115
Firefox Browser Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 112
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 207
jQuery Eclipse IDE Firefox Browser
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
money grubbing section goes here:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic