wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "object" Watch "object" New topic
Author

object

geetanjali rajput
Greenhorn

Joined: Apr 02, 2002
Posts: 19
i really need to ask this. can i say an object is the blue print of a class?. can i say an object is the class itself? i know this is a simple ques. but as a biggener i really need to know it.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by geetanjali rajput:
i really need to ask this. can i say an object is the blue print of a class?. can i say an object is the class itself? i know this is a simple ques. but as a biggener i really need to know it.

I think you have the terminology backwards. A "class" is a blueprint for an "object." A class (as you define in your .java file) describes what data and methods comprise any object of that type. For example. Let's say you have a class called Car:

In this example, I have a class called Car. This is my blueprint. It says that all Cars will have a color, a make, a model, and a year. Also, all cars will be able to drive.
In the main method, I create to Car objects. Each of these is made from the blueprint of the Car class, but each one has its own specific details. For example, the first one if a White, '98 Ford Mustang, while the second is a Black, 2000 Pontiac Grand Prix. They're both Cars, yet they're both distinct objects.
I hope that helps clear that up for you.
Corey


SCJP Tipline, etc.
Dan Lund
Greenhorn

Joined: Jul 17, 2001
Posts: 26
An object is like a recipe for a bread. A class is collection of objects, and methods that uses the objects.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by Dan Lund:
An object is like a recipe for a bread. A class is collection of objects, and methods that uses the objects.

WHAT!?! It seems to me as if you have your terminology reversed, as well. Take a look at my above reply. A class, most definitely, is not a collection of objects.
Corey
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
A "class" is a blueprint for an "object."

Agreed. If you prefer we could use words like "template", "abstraction", "basis" etc... A class, analogously speaking, is a recipe for chocolate chip cookie, while an object is an actual chocolate cookie, a particular chocolate cookie with its own identity .
A class is collection of objects

Well, no, but you can imagine a class as a "something" that a collection of objects has in common. They may all have a certain element (having warm blood, having a certain volume, whatever), or share a common behavior (being able to run, being able to sing, whatever).
I recommend you grab a good OO book. My particular bias is Grady Booch's Object Oriented Analysis and Design where IMHO he has a particularly succinct discussion of the object model. Others will offer their own preferences, surely...
-anthony
[ April 02, 2002: Message edited by: Anthony Villanueva ]
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Perhaps what Dan is trying to say is that when you reference a class, it is loaded into memory one time, in a classfile. That holds all the static variables and the methods.
Then there can be as many objects (instances) of that class as is required. The object only holds the state of the member variables for that instance - so that at any time you know what that particular object's variables values are. Each object of that class has the same blueprint for member variables, but those variables can have different values or references in each instance.


"JavaRanch, where the deer and the Certified play" - David O'Meara
geetanjali rajput
Greenhorn

Joined: Apr 02, 2002
Posts: 19
thanks i appreciate this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: object