This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Mastering Corda: Blockchain for Java Developers and have Jamiel Sheikh on-line!
See this thread for details.
Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Object vs Instance

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys, this is my first thread. My question is,
what is the exact difference between Object and Instance? i want a detailed explanation.

Also i got another question about the exam. I been preparing for the exam(SCJP 1.6) since last year. Even before oracle bought the certification, which is now OCJP. So my question is has oracle changed the syllabus?. and the current version of the exam is 310-065 right? thanks in advance
 
lowercase baba
Posts: 12955
65
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in my mind, 'instance' refers to a specific chunk of memory allocated at runtime that stores the current values for that 'thing'.

'Object' can refer to an instance, but can also refer to the class in general. So, I can use the word 'Object' to talk about Strings and HashTables in general, or the specific instance - "The Object referred to by the myName variable".

Note that there is also a class defined called Object, which is the ultimate class every other class is derived from.
 
Oceana Wickramasinghe
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found this explanation on a website. Is it correct

"When you create a Java object by calling its constructor, the object reference that is returned is called an instance. This means there is little difference between the two terms. The word instance is usually used when we talk about the process of object creation or instantiation, it is a single reference to an object. The word object can also be used to talk collectively about the general properties and behaviour of a Java object."
 
Ranch Hand
Posts: 300
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Oceana Wickramasinghe wrote:I found this explanation on a website. Is it correct

"When you create a Java object by calling its constructor, the object reference that is returned is called an instance. This means there is little difference between the two terms. The word instance is usually used when we talk about the process of object creation or instantiation, it is a single reference to an object. The word object can also be used to talk collectively about the general properties and behaviour of a Java object."



Yes this is correct. In Java we use Object and instance interchangeably but to be precise Object is anything which has state and created in memory while instance ( or reference) is a handle to refer those objects.
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, to be even more precise, a memory reference is a pointer to an instance of a class type, or in other words an object of a class type.

Instance and object mean exactly the same thing, always.

The English word "instance" has a specific definition when used as a noun. This definition has nothing to do with software technology or programming languages such as Java.

When technical authors are writing about Object technology, they can use either the word "instance" to mean an occurence of an "object" or use the term "object" directly. They can do this because in object-oriented terminology the words mean the same thing.
 
I am displeased. You are no longer allowed to read this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic