CBSE Computer Science - Revision Tour(Solved) CBSE Guess > eBooks > Class XII > CBSE Computer Science Object oriented programing Solved Revision Tour By Mr. Ravi Kiran COMPUTER SCIENCE OBJECT ORIENTED PROGEAMING 2005 Delhi: 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. 2 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.) Eg:
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. 2 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 ( mrkdata@yahoo.com ) |