COMPUTER SCIENCE INHERITANCE

DELHI 2004:

2.c) Given the following definitions answer the following:

class livingbeing
{ char specification[20];
int average;
public:
void read();
void show();
};
class ape: private livingbeing
{ int no_of_organs,no_of_bones;
protected:
int iq_level;
public:
void readape();
void showape();
};
class human:public ape
{ char race[20];
char habitation[30];
public:
void readhuman();
};

(i) Name the members, which can be accessed from the member functions of class human.

Ans:

Data Members - ape::iq_level
human::race
human::habitation
Member Function – ape::readape( )
ape::showape( )

(ii) Name the members, which can be accessed by an object of class human.

Ans: Data Members - No data members can be accessed.

Member Functions: ape::readape();
ape::showape();
human::readhuman();

(iii) What will be the size of an object of the (in bytes) of class human?

Ans: 78 Bytes.

DELHI 2003:

2.c) Consider the following and answer the questions given below.

class MNC
{ char Cname[25];
//Company name
protected:
char Hoffice[25]; //Head office
public:
MNC( );
char Country[25];
void EnterData( );
void DisplayData( );
};
class Branch:public MNC
{ long NOE; //Number of Employees
char Ctry[25]; //Country
protected:
void Association( );
public:
Branch( );
void Add( );
void Show( );
};
class Outlet:public Branch
{
char State[25];
public:
Outlet( );
void Enter( );
void Output( );
};

Ans: i) Which class constructor can be called first at the time of declaration of an object of class Outlet?

Ans: MNC class constructor can be called first at the time of declaration of an object of class Outlet.(When an object of the derived class is declared, in order to create it, firstly the constructor of the base class is invoked an then, the constructor of the derived class is invoked. On the other hand, when an object of the derived class is destroyed, first the destructor of the derived class is invoked followed by the destructor of the base class).

ii) How many bytes does an object belonging to class Outlet require?

Ans: 133 Bytes

iii) Name the member function(s) which are accessed from the object(s) of class Outlet.

Ans:

Outlet::Enter( )
Outlet::Output( )
MNC::EnterData( )
MNC::DisplayData( )
Branch::Add( )
Branch::Show( )

iv) Name the data member(s), which are accessible from the object(s) of class Branch.

Ans: MNC::Country

 

CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( mrkdata@yahoo.com )


Warning: include_once(../../ebooks-footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/inheritance8.php on line 170

Warning: include_once(): Failed opening '../../ebooks-footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/inheritance8.php on line 170

Warning: include_once(../../../footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/inheritance8.php on line 172

Warning: include_once(): Failed opening '../../../footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/inheritance8.php on line 172