Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Class and Object

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    11
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Class and Object

    Hi, I am new to java.
    what is class and Object exactly?
    All are saying class is blue print and object is the thing. I am not getting that clearly.
    Could you help me


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Class and Object

    Hopefully this analogy will help:

    A class is a "design" blue print, just like a CAD (computer aided design) model of a car. This class can be used to build an object which follows the blueprint (called constructing, or instancing). However, it's important to note that the object is not the class, just like the CAD model is in no way a real car.

    Inside of each class, you define how the object is built (constructors and such), what kind of data the built object can contain, and how that object can be used. This is similar to the blue print for a car. While the a real CAD model doesn't specify manufacturing techniques, they do specify certain specifications that must be met in the construction process. The CAD model will specify how many seats the car will have, what kind of engine is inside of it, etc. etc. It will also specify how that car can be used (the big round thing in front of you is for steering, the pedal on the right makes you go faster, and the pedal in the middle is unused ).

    Now, just as you can use the same basic CAD model to build several types of the same car (say a red 5 liter V8 corvette as opposed to a blue 5.2 liter V8 corvette), objects can take on similar characteristics.

    Now, there's a little bit of terminology. Static refers to anything used in the blueprint, but is constant for all objects of that type. Instance the opposite of static. Between every object build from that model it is possible (note: possible does not mean it has to be) that the object data is different. I can't really think of a clear analogy for this, but hopefully this helps.

  3. The Following User Says Thank You to helloworld922 For This Useful Post:

    jyothishey (January 25th, 2010)

  4. #3
    Junior Member
    Join Date
    Jan 2010
    Posts
    11
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Class and Object

    thank you so much

Similar Threads

  1. Object o = new Object(); need help
    By zeeshanmirza in forum Object Oriented Programming
    Replies: 11
    Last Post: January 6th, 2010, 10:01 PM
  2. Object Injection
    By Json in forum Java Programming Tutorials
    Replies: 1
    Last Post: December 4th, 2009, 04:08 AM
  3. how to load a class and type cast to that class?
    By chinni in forum Object Oriented Programming
    Replies: 2
    Last Post: November 9th, 2009, 10:18 AM
  4. Replies: 2
    Last Post: November 5th, 2009, 10:15 PM
  5. Having trouble printing object information in main class
    By KingLane in forum Object Oriented Programming
    Replies: 1
    Last Post: October 11th, 2009, 06:53 PM