| Author |
object and instance
|
Megha Jain
Ranch Hand
Joined: Sep 12, 2005
Posts: 30
|
|
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
Joined: Oct 13, 2005
Posts: 32651
|
|
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
Joined: Sep 12, 2005
Posts: 30
|
|
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
Joined: Sep 15, 2005
Posts: 54
|
|
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..
|
Teach me the art of forgetting, for I always remember wat I have forgotten.
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12909
|
|
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.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Megha Jain
Ranch Hand
Joined: Sep 12, 2005
Posts: 30
|
|
|
Yeah i got it.......... thank u so much to all of u.
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
|
See http://faq.javaranch.com/view?ObjectVsInstance
|
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
|
 |
 |
|
|
subject: object and instance
|
|
|