DEV Community

Cover image for Class And Objects
Yash Shah
Yash Shah

Posted on

Class And Objects

A Class is a blueprint, template, or prototype that defines the variables and the methods common to all objects of the same kind.
Object acts as a member, specimen, or instance of the class.
Alt Text
Objects help programmers to use variables and methods as specified in the class.

Classes have logical existence and Objects have a physical existence.

Enough theory🥱, Let's take a real-world example of the laptop💻 on which you might be reading this tutorial:

Take a laptop class has:

  • variables(states): Brand, Operating System, Processor, and RAM
  • methods(behavior): start, restart and shutdown Alt Text

Now, Let's real objects i.e real Laptops which follow the same blueprint as specified in the laptop class:

Object LAP-01:Alt Text
Object LAP-02:Alt Text

Taking look at these two objects: LAP-01 and LAP-02, You will observe that they have differences but they share the same prototype as specified in the parent class.

Thus, Class is a sketch while Object is the same sketch of a parent class with different colors.

Top comments (0)