DEV Community

Adarsh Gautam
Adarsh Gautam

Posted on

Class And Object

Class :) — Class is a group of object which have common Properties

  1. Class is a set of object which shares common characteristics/ behavior and common properties/ attributes.

  2. Class is not a real-world entity. It is just a template or blueprint or prototype from which objects are created.

  3. Class does not occupy memory.

  4. Class is a group of variables of different data types and a group of methods.

For Examples :

Class is a 10th Standard and 10th Standard is a group of Student (many Student) . Then class is a 10th is Standard.

Object :) — Object is a represents real-life entities.An object is called an instance of a class.

An object consists of :

  1. State: It is represented by attributes of an object. It also reflects the properties of an object.
  2. Behavior: It is represented by the methods of an object. It also reflects the response of an object with other objects.
  3. Identity: It gives a unique name to an object and enables one object to interact with other objects

For example, suppose Bicycle is a class then MountainBicycle, SportsBicycle, TouringBicycle, etc can be considered as objects of the class.

Oldest comments (0)