You are on page 1of 2

Lesson 3

What is an object?
An object is a real world entity which have some characteristics and behavior. It
is an instance of a class.

State of an object – The object may be in any state, either processed or


unprocessed.

Behavior of an object – This refers what an object is capable of doing.

Eg: Dogs have state (name, color, breed, hungry) and behavior (barking, fetching,
wagging tail).

What is a class?
Class is a group of similar objects. It acts as a blueprint based on which the objects
are created so it is known as an object factory.

Eg: Let us consider a class called Car based on which different manufactures build
cars sharing some common properties.
(Lesson 3 Continued…)

Class as user defined data type – When a user creates a class it becomes a data
type for the program. We can use the class to create objects of class type.

Class as abstraction – Abstraction is thinking based on general ideas rather than


our real world things and events. An object may refer the features from many
classes that define abstraction.

Objects as instance of class – An object implements the class in real world. It


posses all the characteristics and behavior of the class. That is why it is known as
an instance of a class.

Test your Skills:


Q1. What is an Object in OOP? Give one example.
Q2. Define the term class in OOP.
Q3. Why is object called an instance of a class?
Q4. Differentiate between an object and a class.
Q5. What do you mean by state and behavior of an object?

You might also like