CBSE Computer Science - Revision Tour(Solved)
COMPUTER SCIENCE OBJECT ORIENTED PROGEAMING
2.a) Define the term Data Hiding in the context of Object Oriented Programming. Give a suitable example using a C++ code to illustrate the same.
Ans: A class groups its members into three sections: private, protected and public. The private and protected members remain hidden from outside world. Thus through private and protected members, a class enforces data – hiding.
(The outside world is given only the
essential and necessary information through
public members, rest of the things remain
hidden, which is nothing but abstraction. The
act of representing only essential features
without including background details is
known as abstraction.)
In the above class public members(ie e,fand disp( )) only will be available to outside the class.. The other private members (a,b),protected members (c,d) will not be available to outside the class. This concept is called data hiding.
2005 Outside Delhi:
2.a) Define the term Data Encapsulation in the context of Object Oriented Programming.Give a suitable example using a C++ code to illustrate the same.
Ans: Encapsulation is wrapping up of characteristics and behavior into one unit. While implementing encapsulation, following things are taken care:
Benefits with encapsulation:
CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( [email protected] )