tags:

views:

500

answers:

4

Hi,

Could anyone please what the following is saying about instance and object:

If class is the general representation of an object, an instance is its concrete representation.

I know concrete means non-abstract. So what's actually general representation and concrete representation?

+1  A: 

"General" means, "describes what things of this sort are like; what qualities they share." "Concrete" means, "what is particular to this one; what differentiates it from others of its type."

Carl Manaster
+9  A: 

Car is a general representation having attributes (wheels, doors, colour, etc) and behaviour (start, stop, brake, accelerate, change gears, etc), also called a class.

Bob's Ford Focus (red, license plate LH 12 233) is an instance of class Car, also called an object.

cletus
+6  A: 

My best advise would be to drop the dictionary.. looking up what concrete means and than trying to apply the definition to understanding what an author meant when he or she used concrete representation to describe an instance of an object is just wrong.

Look for other explanations of what objects, classes and instances of objects are, and I'm sure you'll find many with great examples.

Basically you could think of the class as a "recipe" or as a "template" (although I'm reluctant to say template for fear of causing confusion) and an instance as an "embodiment" of said recipe or template.. hence the concrete representation.

So you have the following, which is a class (the recipe):

class Human
{
  private string Name;
  private int Age;

  public void SayHello()
  {
      // run some code to say hello
  }

  public Human(string name, int age)
  {
     Name = name;
     Age = age;
  }
}

And these are instances (objects)..

 Human mike = new Human("Mike", 28);
 Human jane = new Human("Jane", 20);
 Human adam = new Human("Adam", 18);

They are embodiments, or concrete representations of our Human class.

Miky Dinescu
+1  A: 

In Java Context :

Object: That is the Class Instance: The thing created when you use the class.

EX: (to use the above car example) In the below example "Car" is the Object and myInstanceOfCar is the Instance.

class Car
  private String color;

  public static void main(String[] args)
  {

    Car myInstanceOfCar = new Car();
  }
}
Ben