Repaso
EspaƱol

What is the relationship between a class and an object?

Options

  1. They are the same thing under two different names
  2. A class is a blueprint; an object is something built from it (Correct option)
  3. An object is a blueprint that is used to create classes
  4. Classes exist only at runtime and objects only in the code

Answer

A class is a blueprint; an object (instance) is a concrete thing built from it

Why

A class describes what data and behavior something has, like the plan of a house. An object is one real house built from that plan.

You can create many objects from one class, each with its own data: ana = User("Ana") and luis = User("Luis") are two objects of the class User.

Remember

Class = blueprint. Object = one thing built from it.

Key terms

Practice this question in Repaso