31.2k views
4 votes
In Objected Oriented Terminology, what is the relationship between instances, classes and objects? instances, objects and classes are the same thing a class is an object of an instance an object is an instance of a class instances are specific names for object classes

1 Answer

3 votes

Step-by-step explanation:

an object is an instance of a class.

a class is a container of objects. it just describes the types of objects it may contain.

like a box of cards, a box of cars, a box of watches, ...

because of that description you know for example, when you see an actual car, that it is a car. in the other hand you have the guarantee that when you pick any item (object) from the box car, then it truly is a car.

so, when you instantiate the box car, you actually manufacture a car based on the standard description and on some specific attributes (wishlist about some details), and then you put it into that box.

the tricky part is that classes can also instantiate other classes. but only an object is supposed to actually doing things (execute instructions). an object is therefore a kind of a leaf on the tree of classes.

that is a bit rough and incomplete, but it should give you an idea about the basic meaning of these terms.

User Martin Boros
by
7.7k points