CBSE eBooks CBSE Guess > eBooks > Class XII > Computer Science By . Mr. MRK
Chapter – 3. OBJECT ORIENTED PROGRAMMING 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. In the above class public members(ie e,f and 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:
A class binds together data and its associated functions under one unit thereby enforcing encapsulation. |