Chapter 16: Inheritance - Online Test

Q1. Which amongst the following is executed in the order of inheritance?
Answer : Option C
Explaination / Solution:
No Explaination.


Q2. Which of the following is true with respect to inheritance?
Answer : Option B
Explaination / Solution:
No Explaination.


Q3.

Based on the following class declaration answer the question

class vehicle

{ int wheels;

public:

void input_data(float,float);

void output_data();

protected:

int passenger;

};

class heavy_vehicle : protected vehicle {

int diesel_petrol;

protected:

int load;

protected:

int load;

public:

voidread_data(float,float)

voidwrite_data(); };

class bus: private heavy_vehicle {

charTicket[20];

public:

voidfetch_data(char);

voiddisplay_data(); };

};

Which is the base class of the class heavy_vehicle?

Answer : Option C
Explaination / Solution:
No Explaination.


Q4.

Based on the following class declaration answer the question

class vehicle

{ int wheels;

public:

void input_data(float,float);

void output_data();

protected:

int passenger;

};

class heavy_vehicle : protected vehicle {

int diesel_petrol;

protected:

int load;

protected:

int load;

public:

voidread_data(float,float)

voidwrite_data(); };

class bus: private heavy_vehicle {

charTicket[20];

public:

voidfetch_data(char);

voiddisplay_data(); };

};

The data member that can be accessed from the function displaydata()

Answer : Option C
Explaination / Solution:
No Explaination.


Q5.

Based on the following class declaration answer the question

class vehicle

{ int wheels;

public:

void input_data(float,float);

void output_data();

protected:

int passenger;

};

class heavy_vehicle : protected vehicle {

int diesel_petrol;

protected:

int load;

protected:

int load;

public:

voidread_data(float,float)

voidwrite_data(); };

class bus: private heavy_vehicle {

charTicket[20];

public:

voidfetch_data(char);

voiddisplay_data(); };

};

The member function that can be accessed by an objects of bus Class is

Answer : Option C
Explaination / Solution:
No Explaination.


Q6.

Based on the following class declaration answer the question

class vehicle

{ int wheels;

public:

void input_data(float,float);

void output_data();

protected:

int passenger;

};

class heavy_vehicle : protected vehicle {

int diesel_petrol;

protected:

int load;

protected:

int load;

public:

voidread_data(float,float)

voidwrite_data(); };

class bus: private heavy_vehicle {

charTicket[20];

public:

voidfetch_data(char);

voiddisplay_data(); };

};
The member function that is inherited as public by Class Bus
Answer : Option C
Explaination / Solution:
No Explaination.


Q7.

class x

{ int a; public : x()

{}

};

class y

{ x x1; public : y(){} };

class z : public y,x

{

int b; public: z(){} }z1; 

What is the order of constructor for object z1 to be invoked?

Answer : Option D
Explaination / Solution:
No Explaination.