CBSE Computer Science - Revision Tour(Solved) CBSE Guess > eBooks > Class XII > CBSE Computer Science Class And Object Solved Revision Tour By Mr. Ravi Kiran COMPUTER SCIENCE CLASS AND OBJECTS 2008 Delhi: 2.a) Differentiate between public and private visibility modes in context of Object Oriented Programming using a suitable example illustrating each. Ans: public and private visibility modes in
context of OOP: Public visibility mode: The public derivation means that the derived class can access the public and protected members of the base class but not the private members of the base class. With publicly derived class, the public members of the base class become the public members of the derived class, and the protected members of the base class become the protected members of the derived class. Private visibility mode: The private derivation means, the derived class can access the public and private members of the base class privately. With privately derived class, the public and protected members of the base class become private members of the derived class. That means the inherited members can be accessed only through member functions of the derived class.
public and private access specifiers in context of OOP: public access specifier isused to define any method or a variable which may be accessed by any member function of the same class and also from outside the class. Private access specifier is used to make
any variable or a method which has a limited access within the class only.The concept of private access specifier only. Eg:
2008 Outside Delhi: 2.a) Differentiate between private and protected visibility modes in context of objectoriented programming using a suitable example illustrating each. Ans:private and protected visibility modes in context of OOP: Private visibility mode: The private derivation means, the derived class can access the public and private members of the base class privately. With privately derived class, the public and protected members of the base class become private members of the derived class. That means the inherited members can be accessed only through member functions of the derived class. Protected visibility mode: The protected derivation means that the derived class can access the public and private members of the base class protectedly. With protectedlyderived class, the public and protected members of the base calss become protected members of the derived class. That means the inherited members are now not available tothe outside world and can be accessed only through the member functions of the derived class and the classes based upon the derived classes. These members can be inherited further if any classes are inheriting from the derived class.
private and protected access specifiers in context of OOP: Eg:
CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( mrkdata@yahoo.com ) |