• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

object and instance

 
Megha Jain
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Can you please tell me..........
when i say...

Object is an instance of a class....

What is the difference between object and instance....... how can i define instance?
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right that
Object is an instance of a class.
Any representation of something in Java programming is called an object. So object is a rather non-specific general term. every object has to arise from a class.

If you talk about an object arising from a particular class, you don't call it an object of class XYZ, but an instance of class XYZ.

Does that make it clearer? Or more obscure?

CR
 
Megha Jain
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks...... i got it.

Actually i read this question "what is the difference between object and instance? which was asked in interview.

So i want to know how to answer this to an interviewer...... so that i can tell him what he wants to hear
 
jaspal singh
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi megha,

in object oriencted terminology:
u talk about an object as a blueprint.and the instance is the entity made on that blue print.

for e.g.:u design a car model with its features and sepcification on a paper.then u follow that sketch to create a reall car. the first is object while the second is the instance.


i hope u are clear..
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by jaspal singh:
in object oriencted terminology:
u talk about an object as a blueprint.and the instance is the entity made on that blue print.


You meant: You talk about a class as a blueprint (not an object). Objects are instances of classes, and so are the concrete entities made from the blueprint.
 
Megha Jain
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah i got it.......... thank u so much to all of u.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See http://faq.javaranch.com/view?ObjectVsInstance
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic