aspose file tools*
The moose likes Beginning Java and the fly likes object and instance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "object and instance" Watch "object and instance" New topic
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: 40052
    
  28
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
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14430
    
  23

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 8 API documentation
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