CBSE eBooks CBSE Guess > eBooks > Class XII > Computer Science By . Mr. MRK
Chapter – 6. INHERITANCE OUTSIDE DELHI 2008 2.d. Answer the questions (i) to(iv) based on the following code : class Toys (i) Which type of Inheritance is shown in the above example? Ans: Hierarchical Inheritance. Since the sub classes are derived from a single base class(Dolls). (ii) How many bytes will be required by an object of the class SoftToys ? Ans: 33 Bytes (Explonation: The memory will be reserved as follows: char Tcode[5]; //5 Bytes float Price; //4 Bytes char STName[20]; //20 Bytes float Weight; // 4 Bytes Total = 33 Bytes) (iii) Write name of all data members accessible from member function of the class SoftToys. Ans: Toys::Price, SoftToys::STName, SoftToys::Weight (iv) Write name of member functions accessible an object of the class ElectronicToys ? Ans: ElectronicToys::ETEntry( ), Electronic Toys::ETDisplay( ), Toys::TEntry( ), Toys::TDisplay( ) DELHI 2007 2.d. Answer the questions (i) to(iv) based on the following code:4 class Trainer (i) Which type of inheritance is depicted by above example ? Ans: Multiple Inheritance. Since here the class Institute is deriving from the classes Learner and Trainer. (ii) Identify the member function(s) that cannot be called directly from the objects of class Institute from the following TEntry() LDisplay() IEntry() Ans: All the above 3 member functions can be called directly from the objects of class Institute. (iii) Write name of all member(s) accessible from member functions of class institute. Ans: Data Members – Trainer::Remuneration, Member functions – Trianer::AssignRem( ), (iv) If class institute was derived privately from class Learner and privately from class Trainer, then name the member function(s)that could be accessed through Objects of class Institute. Ans: Institute::IEntry( ), Institute:: IDisplay( ), |
|