Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 4

OBJECTS

1.What is an object? Give some examples of some real world


objects.

Ans:An object is an identifiable entity with some characteristics


and behavior.For instance,a ball,a table,a dog,etc. are all
examples of real life objects as they all have some specific
physical characteristics and a distinct behavior.

2."An object's state and behavior are two distinct things yet
linked to one another"-comment.

Ans:The state of an object controls its behavior and the behavior


of an object can bring about a change in its state,thus the state
and the behavior of an object are related to each other.

3.Define data abstraction.

Ans:Data abstraction means the representing only those


essential features of an entity,which are meaningful for a
particular application or concept.For instance,on a
switchboard,only the switches are exposed which are necessary
for a switchboard to operate-rest everything such as wires,etc. is
hidden.This is data abstraction.

4.Define encapsulation.

Ans:Data encapsulation refers to wrapping up the


characteristics,state and behavior(i.e.data and functions) of an
entity in a single unit.
For instance,a group of car parts such as
seats,steering,motor,breaks,etc. does not make a car,they have
to be connected in a proper way in one unit in order to have
proper functionality i.e. behavior-then only may it be termed as
car.
5.What is message passing among objects?

Ans:The interaction between objects,by means of function calls


is termed as message passing.For instance,a customer object
may want to interact with an account object for viewing the
balance amount.For this,the customer object will pass amessage
requesting the display of a balance amount to account object.

6.What are methods?What do they represent?

Ans:The functions added to an object are called its methods and


they represent the behavior of the object or entity.For
example,the functions move,halt,accelerate,stop,etc. represent a
vehicle's behaviors-these are methods.

7.How are objects implemented in software terms?

Ans:The object is implemented in software terms as follows:-


a)Characteristics or attributes are implemented through member
variables or data items of the object.
b)Behavior is implemented through member functions called
methods.
c)It is given a unique name to give it identity.

8.How is data abstraction associated with encapsulation?

Ans:Abstraction is the act of representing essential features


without including background details.Encapsulation is the way of
combining both data and the functions that operate on the data
under a single unit.
Encapsulation is the way of implementing astraction.Data
abstraction involves representing an entity by using its essential
features whereas data encapsulation is the act of wrapping the
data and the functions associated with an entity in a single
unit.Data abstraction can be said to be the basis or the ground
work for data encapsulation.
9.Encapsulation is one of the major properties of OOP-object
oriented programming. How is it implemented in software terms?

Ans:Encapsulation is a way to implement data hiding by wrapping


up data and associated functions into a single unit known as
object.An object binds together data and its associated functions
under one unit,thereby enforcing encapsulation,as encapsulation
means wrapping up data and associated functions together into a
single unit.

10."There can be many abstractions for an object"-comment.

Ans:Abstraction of an object or an entity depends upon the


application it is to be used in.For example,a person can be an
employee as well as a member of a family.Now from the point of
view of the company in which the person works,his/her
department,designation,salary,etc. would represent the state of
the person.At the same time,if the government decides to
conduct a census,then the state of the same person might be
represented by his/her gender,age,address,etc.Thus depending
upon the problem domain,the same entity can have many
abstractions.

11.How does an object encapsulate its state and behavior?

Ans:As we know that an object is an identifiable entity with some


characteristics and behavior,the state of an object depends upon
the value of its attributes at any given time.
Since,state and behavior of objects are interlinked,they are said
to encapsulate state and behavior.For instance,a car object has
characteristics like number of wheels,seats,make,etc.Its
behavior is represented as it can move,stop,blow horn,etc.Now
all these are wrapped up together in the form of a car.We cannot
segregate them.Thus,we can say that objects encapsulate their
state and behavior and as their state and behavior are
interlinked,they cannot exist separately.

12.How do objects interact with one another?Give example.


Ans:Objects interact with each other by means of
messages,which are nothing but function calls.This interaction
of objects is also known as message passing.In message
passing,an object sends/passes a request to another object by
invoking a function of the object's class,and then the object
responds as per the function that is invoked.let us consider the
objects account and employee.The object employee would often
need to communicate with the object account on order to find
out the current balance or to carry out withdrawals and
deposits.This interaction between the objects is carried out by
means of methods defined in the objects.For example,the object
account must implement the behavior(methods)-check
balance,withdraw and deposit so that the object employee can
interact with it.

You might also like