TN Board 11th Computer Science Important Questions Chapter 16 Inheritance

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance

Question 1.
What is derived class?
Answer:
A class that inherits from a superclass is called a subclass or derived class

Question 2.
Write the advantages of inheritance.
Answer:
The main advantages of inheritance are:

  1. It represents real world relationships well
  2. It provides reusability of code (Hi) It supports transitivity

Question 3.
What are the different types of inheritance?
Answer:
The different types of inheritance are Single Inheritance, Multiple inheritance, Multilevel inheritance, hybrid inheritance and Hierarchical inheritance.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 4.
What is Hybrid inheritance?
Answer:
When there is a combination of more than one type of inheritance, it is known as hybrid inheritance. Hence, it may be a combination of Multilevel and Multiple inheritance or Hierarchical and Multilevel inheritance or Hierarchical, Multilevel and Multiple inheritance.

Question 5.
What is the use of ‘this’ pointer?
Answer:
‘this’ pointer is a constant pointer that holds the memory address of the current object. It identifies the currently calling object. It is useful when the argument variable name in the member function and the data member name are same. To identify the data member it will be given as this→data member name.

Question 6.
Give the use of scope resolution operator in derived class with example.
Answer:
In inheritance the member function of the base class and derived classes have the same name. If the derived class object calls
t1.1oo( );
t2.1oo( );
}
Output:
5 5
5 5

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 7.
Give the example for executing the order of constructors and destructors.
Answer:
When an object of the derived class is created, the compiler first calls the base class constructor and then the constructor of the derived class. This is because the derived class is built up on the members of the base class. When the object of a derived class expires first the derived class destructor is invoked followed by the base class destructor.
The order of constructors and destructors.
#include<iostream>
using namespace std;
class base
{
public:
base ( )
{
cout<<“:\nConstructor of base class . . .”;
}
~ base ( )
{
cout<<“\nDestructor of base class . . .”;
}
};
class derived:public base
{
public :
derived( )
{
cout<<“\nConstructor of derived . . .”;
}
~ derived( )
{
cout<<“\nDestructor of derived . . .”;
}
};
class derived1 :public derived
{
public :
derived1( )
{
cout<<“\nConstructor of derived1 . . .”;
}
~ derived1( )
{
cout<<“\nDestructor of derived1 . . .”;
}
};
int main( )
{
derived1 x;
return 0;
}
Output:
Constructor of base class…
Constructor of derived …
Constructor of derived1 …
Destructor of derived1 …
Destructor of derived …
Destructor of base class….

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 8.
What is single inheritance? Give example.
Answer:
When derived class inherits only from one base class, it is known as single inheritance. Though the derived class inherits all the members of base class, it has access privillege only to non-private members of the base class.

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance 1

Program to illustrate single inheritance:
#include<iostream>
using namespace std;
class student //base class
{
private :
char name[20];
int rno;
public:
void acceptname( )
{
cout<<“\n Enter roll no and name . . .”;
cin>>rno>>name;
}
void displayname( )
{
cout«”\n Roll no :-“<<rno;
cout<<“\n Name : -“<<name<<endl;
}
};
class exam : public student
//derived class with single base class
{
public:
int mark1, mark2, mark3, mark4, mark5, mark6, total;
void acceptmark( )
{
cout<<“\n Enter lang, eng, phy, che, esc, mat marks . .”;
cin>>markl>>mark2>>mark3>>mark4> >mark5>>mark6 ;
}
void displaymark( )
{
cout<<“\n\t\t Marks Obtained”;
cout<<“\n Language..”<<mark1;
cout<<“\n English..”<<mark2;
cout<<“\n Physics..”<<mark3;
cout<<“\n Chemistry. ,”<<mark4;
cout<<“\n Comp . sci . . “<<mark5;
cout<<“{\n Maths..”<<mark6;
}
};
int main( )
{
exam e1;
e1.acceptname( ); //calling base class function using derived class object el.acceptmark( ) ;
e1.displayname( ); //calling base class function using derived class object el.displaymark( ) ;
return 0;
}
Output:
Enter roll no and name.. 1201 KANNAN
Enter lang, eng, phy, che, esc, mat marks.. 100 100 100 100 100 100
Roll no:- 1201
Name:- KANNAN
Marks Obtained Language.. 100
English .. 100
Physics .. 100
Chemistry.. 100
Comp.sci.. 100
Maths .. 100

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 9.
What is Multiple Inheritance? Give example.
Answer:
When a derived class inherits from multiple base classes it is known as multiple inheritance.
Program to illustrate Multiple inheritance:
The order of inheritance by derived class to inherit the base class is left to right

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance 2

#include<iostream>
using namespace std;
class student //base class
{
private:
char name[20];
int rno;
public:
void acceptname( )
{
cout<<“\n Enter roll no and name . .”;
cin>>rno>>name;
}
void displayname( )
{
cout<<“\n Roll no :-“<<rno;
cout<<“\n Name :-“<<name<<endl;
;
}
};
class detail //Base class
{
int dd, mm, yy;
char cl [4];
public:
void acceptdob( )
{
cout<<“\n Enter date,month,year in digits and class . .”;
cin>>dd>>mm>>yy>>cl;
}
void displaydob( )
{
cout<<“\n class :-“<<cl;
cout<<“\t\t DOB: “<<dd<<“-” <<mm<<“-“<<yy<<endl;
}
};
class exam : public student, public detail
//derived class with multiple base class
{
public:
int mark1, mark2, mark3, mark4, mark5, mark6, total;
void acceptmark( )
{
cout<<“\n Enter lang, eng, phy, che, esc, mat marks..”;
cin>>mark1>>mark2>>mark3>>mark4>>mark5>>mark6;
}
void displaymark( )
{
cout<<“\n\t\t Marks Obtained”;
cout<<“\n Language..”<<mark1;
cout<<“\n English .. “<<mark2 ;
cout<<“\n Physics . . “<<mark3;
cout<<“\n Chemistry..”<<mark4;
cout<<“\n Comp.sci..”<<mark5;
cout<<“\n Maths..”<<mark6;
}
};
int main( )
{
exam e1;
e1.acceptname( ); //calling base class function using derived class object
e1.acceptdob( ); //calling base
class function using derived class object el.acceptmark( );
e1.displayname( ); //calling base class function using derived class object
e1.displaydob( ); //calling base class function using derived class object
e1.displaymark( );
return 0;
}
Output:
Enter roll no and name .. 1201 MEENA
Enter date,month,year in digits and class..7 12 2001 XII
Enter lang,eng,phy,che,esc,mat marks.. 96 98 100 100 100 100
Roll no :-1201
Name :- MEENA
class :-XII
DOB : 7-12-2001
Marks Obtained
Language.. 96
English .. 98
Physics .. 100
Chemistry.. 100
Comp.sci.. 100
Maths .. 100

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 10.
Differentiate Inheritance and polymorphism.
Answer:

Inheritance

 Polymorphism

Inheritance is creating a class that derives its feature from an already existing class.  Polymorphism is an interface that can be defined in multiple forms.
It is implemented on the classes.  It is implemented on methods/functions.
As inheritance allows a derived class to use the elements and methods defined in the base class, the derived class does not need to define those elements or method it again, So it increases the code reusability and hence, reduce the length of the code.  Polymorphism makes it possible for an object to decide what form of the method it wants to invoke at both compile time and run time.
It can be classified as single inheritance, multiple inheritance, multi level inheritance, hierarchical inheritance and hybrid inheritance.  It is classified as overloading and overriding.

Question 11.
Consider the following C++ code and answer the question from (i) to (iv).
Answer:
class shop
{
int Id;
char Name[20]
protected:
float Qty;
public:
shop( );
void Enter_details( );
void View_details();
};
class salesman
{
int Dcode;
protected:
char Manager[20]
public:
sale( );
salesman( );
void Enter_details( );
void View_details( );
};
class sale : public shop, private salesman
{ .
char Name[20], Location[20];
public:
sale( );
void Enter_All( );
void View_All( );
};
(i) Which type of inheritance out of the following is illustrated in the above example?
(ii) Write the names of all the data members, which are directly accessible from the member functions class sale().
(iii) Write the names of all the member functions, which are directly accessible by an object of class sale.
(iv) Which will be the order of execution of the constructors, when an object ©f class sale is declared?
Answer:
(i) Multiple Inheritance
(ii) Name, Location, Manager, Qty
(iii) Enter_MI( ),View_MI( ),Enter_Dttails( ), View_Details( )
(iv) shop( ), salesman( ), sale( ).

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 12.
Explain the significance of different visibility mode for the program given below.
//Implementation of Single Inheritance using public visibility mode
#include <iostream>
using namespace std;
class Shape
{
private:
int count;
protected:
int width;
int height;
public:
void setWidth(int w)
{
width = w;
}
void setHeight(int h)
{
height = h;
} };
class Rectangle: publicShape
{
public:
int getArea( )
{
return (width * height);
}
};
int main( )
{
Rectangle Rect;
Rect.setWidth(5);
Rect.setHeight(7);
// Print the area of theobject.
cout<< “Total area:”<<Rect.getArea( )<<endl;
return 0;
}
Output:
Total area: 35
The following table contains the members defined inside each class before inheritance.

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance 3

The following table contains the details of members defined after inheritance.

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance 4

Suppose the class rectangle is derived with protected visibility then the properties of class rectangle will change as follows:

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance 5

In case the class rectangle is derived with private visibility mode from its base class shape then the property of class rectangle will change as follows:

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance 6

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 13.
Explain the concept of hybrid inheritance with example.
Answer:
Program to illustrate hybrid inheritance:

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance 7

#include<iostream>
using namespace std;
class student //base class
{
private:
char Name [20];
int rno;
public:
void acceptname( )
{
cout<<“\n Enter roll no and name . . . “;
cin>>rno>>name;
}
void displacement( )
{
cout«”\n Roll no :-“«rno;
Cout<C’\n Name :-“«name«endl;
class exam : public student I/derived class with single base class
public:
mt markl,mark2,mark3,mark4,
mark5, mark6;
void acceptmark( )
cout<<”\n Enter lang,eng,phy,che,csc,mat marks. .“;
cin>>mark1>>mark2>>mark3>>mark4>>mark5>>mark6;
void displaymark( ) {
cout<<’\n\t\t Marks Obtained”;
cout<<”\n Language. .“<<markl;
cout<<’\n English. .“<<mark2;
cout<<”\n Physics. . “<<mark3;
cout<<”\n Chemistry. . “<<mark4;
cout<C’\n Comp.sci. .“<<markS;
cout<<”\n Maths. . “<<mark6;
}
};
class detail //base class 2
irit dd, mm, yy;
char cl[4];
public:
void acceptdob( )
{
cout<<”\n Enter date,month,year in digits and class. .“;
cin>>dd>>mm>>yy>>cl;
}
void diplaydob( )
{
cout<<”\n class:—”<<cl;
coutc<<”\t\t DOB: “<<dd<<”—”<<mm<<”-”<<yy<<endl;
}
};
class result : public exam,public detail I/inherits from exam ,which itself is a //derived class and also from class detail
{
int total;
public:
void showresult( )
{
total=mark1+mark2+mark3+mark4+mark5+mark6;
cout<<” \nTOTAL MARK SCORED: “<<total ;
}
};
int main( )
{
result r1;
r1.acceptname( ); //calling base class function using derived class object
r1.acceptmark( ); //calling base class which itself is a derived class function using its derived class object •
r1.acceptdob( );
cout<<“\n\n\t\t MARKS STATEMENT”;
r1.displayname( ); //calling base class function using derived class object
r1.displaydob( );
r1.displaymark( ); //calling base class which itself is a derived class function using its derived class object r1.showresult( ); //calling the child class function return 0;
}
Output:
Enter roll no and name.. 1201 RAGU
Enter lang,eng,phy,che,esc,mat marks..96 98 100 100 100 100
Enter date,month,year in digits and class.. 7 12 2001 XII MARKS STATEMENT
Roll no :-1201
Name :-RAGU
class :-XII
DOB : 7-12-2001
Marks Obtained
Language.. 96
English .. 98
Physics .. 100
Chemistry.. 100
Comp.sci.. 100
Maths .. 100
TOTAL MARK SCORED : 594
In the above program the derived class “result” has acquired the properties of class “detail” and class “exam” which is derived from “student”. So this inheritance is a combination of multi level and multiple inheritance and so it is called hybrid inheritance.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 14.
Explain the concept of hierarchical inheritance.
Answer:
Program to illustrate Hierarchical inheritance:

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance 8

#include<iostream>
using namespace std;
class student //base class
{
private:
char name[20];
int rno;
public:
void acceptname( )
{
cout<<“\n Enter roll no and name . . .”;
cin>>rno>>name;
}
void displayname( )
{
cout<<“\n Roll no:-“<<rno;
cout<<“\n Name: -“<<name<<endl;
} .
};
class qexam : public student //derived class with single base class
{
public:
int mark1, mark2, mark3, mark4, mark5, mark6;
void acceptmark( )
{
cout<<“\n Enter lang, eng, phy, che, esc, mat marks for quarterly exam..”; cin>>mark1>>mark2>>mark3>>mark4>>mark5>>mark6;
}
void displaymark( )
{
cout<<“\n\t\t Marks Obtained in quarterly”;
cout<<“\n Language. . “<<mark1;
cout<<“\n English ..”<<mark2;
cout<<“\n Physics ..”<<mark3;
cout<<“\n Chemistry.. “<<mark4;
cout<<“\n Comp. sci . . “<<mark5;
cout<<“\n Maths..”<<mark6;
}
};
class exam : public student //derived class with single base class
{
public:
int mark1, mark2, mark3, mark4, mark5, mark6;
void acceptmark( )
{
cout<<“\n Enter lang, eng, phy, che, esc, mat marks for halfyearly exam..”; cin>>mark1>>mark2>>mark3>>mark4>>mark5>>mark6;
}
void displaymark( )
{
cout<<“\n\t\t Marks Obtained in Halfyearly”;
cout<<“\n Language.. “<<mark1;
cout<<“\n English.. “<<mark2;
cout<<“\n Physics..”<<mark3;
cout<<“\n Chemistry.. “<<mark4;
cout<<“\n Comp. sci .. “4<mark5;
};
int main( )
{
qexam q1;
hexam h1;
ql.acceptname ( ); //calling base class function using derived class object
ql.acceptmark( ); //calling base class function
hi.acceptname( ); //calling base class function using derived class object
hi.displayname( );//calling base class function using derived class object .
hi.acceptmark( ) ;
hi.displaymark( ); //calling base class function using its //derived class object
return 0;
}
Output:
Enter roll no and name .. 1201 KANNAN
Enter lang,eng,phy,che,esc,mat marks for quarterly exam.. 95 96 100 98 100 99
Roll no :-1201
Name :-KANNAN
Marks Obtained in quarterly
Language.. 95
English .. 96
Physics .. 100
Chemistry.. 98
Comp.sci.. 100
Maths .. 99
Enter roll no and name .. 1201 KANNAN
Enter lang,eng,phy,che,esc,mat marks for halfyearly exam..
96 98 100 100 100 100 Roll no :-1201
Name:- KANNAN .
Marks Obtained in Halfyearly
Language.. 96
English .. 98
Physics .. 100
Chemistry.. 100
Comp.sci.. 100
Maths .. 100
In the above program, the class “qexam” and “hexam” are derived from class “student”. Here for single base class more than one derived class. So this comes under hierarchical inheritance.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 15.
Explain the concept of multilevel inheritance. Illustrate with an example.
Answer:
In multilevel inheritance, the level of inheritance can be extended to any number of level depending upon the relation. Multilevel inheritance is similar to relation between Grand Father, Father and child.
Program to illustrate multilevel inheritance:

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance 9

#include<iostream>
using namespace std;
class student //base class
{
private: char name[20]; int rno; public:
void acceptname( )
cout<<“\n Enter roll no and name..”;
cin>>rno>>name;
}
void displayname( )
{
Multilevel Inheritance
cout<<“\n Roll no:-“<<rno;
cout<<“\n Name :-“<<name<<endl;
}
};
class exam : public student //derived class with single base class
{
public:
int mark1, mark2, mark3, mark4, mark5, mark6;
void acceptmark( )
{
cout<<“\nEnter lang,eng,phy,che,esc,mat marks..”;
cin>>markl>>mark2>>mark3>>mark4>>mark5>>mark6;
}
void displaymark( )
{
cout<<“\n\t\t Marks Obtained”;
cout<<“\n Language. . .”<<mark1;
cout<<“\n English…”<<mark2;
cout<<“\n Physics… “<<mark3;
cout<<“\n Chemistry. .. “<<mark4;
cout<<“\n Comp.sci. . . “<<mark5;
cout«”\n Maths… “<<mark6;
}
} ;
class result : public exam
{
int total; public
void showresult( )
{
total=mark1+mark2+mark3+mark4 +mark5+mark6;
cout<<“\nTOTAL MARK SCORED :” «total;
}
};
int main( )
{
result r1;
rl.acceptname( ); //calling base class function using derived class object
rl.acceptmark( ); //calling base class function which itself is a derived
// class function using its derived class object
rl.displayname( ); //calling base class function using derived class object
rl.displaymark( ); //calling base class function which itself is a ‘ derived
//class function using its derived class object rl.showresult(); //calling the child class function return 0;
}
Output:
Enter roll no and name .. 1201 SARATHI
Enter lang,eng,phy,che,esc,mat marks.. 96 98 100 100 100 100
Roll no :-1201
Name .–SARATHI
Marks Obtained
Language… 96
English… 98
Physics … 100
Chemistry… 100
Comp.sci… 100
Maths… 100
TOTAL MARK SCORED: 594
In the above program, class “result” is derived from class “exam” which itself is derived from class student.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 16.
All the banks operating in India are controlled by RBI. RBI has set certain guidelines (e.g. minimum interest rate, minimum balance allowed, maximum withdrawal limit etc.,) for all banks to follow. For example, suppose RBI has set minimum interest rate applicable to a saving bank account to be 5% annually; however, banks are free to use 5% interest rate or to set any rates above it.

Write a program to implement bank functionality in the above scenario. Note: Create few classes namely Customer, Account, RBI (Base Class) and few derived classes (SBI, ICICI, PNB, IOB etc.,). Assume and implement required member variables and functions in each class.
Hint:
class Customer
{
//Personal Details…
// Few functions…
}
class Account
{
// Account Detail…
//Few functions…
}
}
class RBI
{
Customer c;//hasA relationship
Account a; //hasA relationship
Public double GetlnterestRate( ) { }
Public double GetWithdrawalLimit( ) { }
}
class SBI: public RBI
{
//Use RBI functionality or define own functionality.
}
class ICICI: public RBI
{
//Use RBI functionality or define own functionality.
}
class IOB: public RBI
{
//Use RBI functionality or define own functionality.
}
Answer:
class customer
{
char c_name[20];
char c_address[30];
int c_phoneno;
public:
void get_customerinfo( )
{
cout<<“\nEnter customer name”<<endl; cin>>c name;
cout<<“\n Enter Customer Address”<<endl; cin>>c_address;
cout<<“\n Enter Customer phone No”<<endl;
cin>>c_phoneno ;
}
void display_customerinfo( )
{
cout<<“Displaying Customer information”<<endl;
cout<<“Custo.mer Name:” <<c_name;
cout<<“Customer Address:” <<c_address;
cout<<“Customer Phone No:” <<cphoneno;
}
class Account
{
char b_name[20];
int account_no;
float balance;
public:
void get_accountinfo ( )
{
_cout<<“Enter Bank Name”<<endl;
cin>>b_name;
cout<<“Enter Account Number”<<endl;
cin>>account_no;
}
};
};
class RBI:Public customer
{
float balance;
public:
double get_withdrawal limit( )
{
float w_amount;
cout<<“\n Enter with draw amount”<<endl;
if(balance-w_amount<1000)
{
cout<<“With draw amount is not possible”<<endl ;
}
balance=balance-w_amount;
}
double interestrate ( )
{
float interest;
interest=(balance*5)/100;
balance=balance+interest;
}
};
class SBI : public RBI
{
int amount;
public: .
SBI(int a)
{
amount = a;
}
int getBalance( )
{
return amount;
}
};
class ICICI : public RBI
{
int amount;
public:
ICICI (int a)
{
amount = a;
}
int getBalance( )
{
return amount;
}
};
class IOB : public RBI
{
int amount;
public:
IOB(int a)
{
amount = a;
}
int getBalance( )
{
return amount;
}
} ;

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 17.
Write a class for a class Stock.
(i) – Each Stock has a data member which holds the net price, and a constructor which sets this price.
– Each Stock has a method get_Price(), which calculates and returns the gross price (the gross price includes VAT at 21%).
Answer:
class Stock
{
private:
float netprice;
public:
Stock (float P)
{
netprice=P;
}
void get_price( )
{
float grossprice, tax;
tax=netprice*21/100;
grossprice=netprice+tax;
cout<<“\n Net Price”<<netprice<<endl;
cout<<“\nTax Amount: “<<tax<<endl;
cout<<“Gross Price: “<<grossprice;
}
};

(ii) Write 2 classes which inherit from the general Stock class, of type Notebook and Book.
– The gross price for Notebook includes tax at 21%.
– Books are free of tax, so the gross price is unchanged from the net price, and you will need to re-define the getGrossPrice method in this class.
Answer:
class Stock
{
public:
float netprice;
Stock (float P)
{
netprice=P;
}
};
class Book : public Stock
{
void get_price()
{
float grossprice,tax; tax=netprice*21/100;
grossprice=netprice+tax;
cout<<“\n Net Price”<<netpr ice<<endl;
cout<<“\nTax Amount: “<<tax<<endl;
cout<<-“Gross Price: “<<grossprice;
}
};
class notebook : public Stock
{
void get_price( )
{
float grossprice;
grossprice=netprice;
cout<<“Gross Price:”<<grossprice;
}

(iii) Write a program which does the following;
(a) Declare an array of 10 objects to Stock.
(b) Declare a object to a Book and an object to Notebook.
(c) Ask the user to enter details of the book, and of the Notebook item.
(d) Check your method getGrossPrice works correctly with each type and then display the result.
Answer:
#include<iostream>
using namespace std;
class stock
{
int Bookcode;
float qty;
float price;
void totalcost( )
{
float tcost;
tcost=price*qty;
cout<<tcost;
}
public:
void bookdetails( )
{
cout<<“Enter the Quantity”<<endl;
cin>>qty;
cout<<“Enter Price”<<endl; .
cin>>price; display( );
}
void display( )
{
cout<<“\nTotal Cost is”<<endl;
totalcost ( );
}
}s[10] ;
int main( )
{
Stock bo,no;
cout<<“\nBook Details”<<endl;
bo.bookdetails( );
cout<<“\nNote book Details”<<endl;
no.bookdetails( );
return 0;
}

Question 18.
What is inheritance?
Answer:
Inheritance is an important feature of object oriented programming used for code reusability. It is a process of creating new classes called derived cljisses, from the existing or base classes. Inheritance allows to inherit all the code (except declared as private) of one class to another class.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 19.
What is a base class?
Answer:
A class that is used as the basis for inheritance is called a super class or base class.

Question 20.
Why derived class is called power packed class?
Answer:
The derived class is a power packed class, as it can add additional attributes and methods and thus enhance its functionality.

Question 21.
In what, multilevel and multiple inheritance differ though both contains many base class?
Answer:

Multilevel inheritance

 Multiple inheritance

The level of inheritance can be extended to any number of level depending upon the relation. Multilevel inheritance is similar to relation between Grand Father, Father and child.  The base classes do not have any relationship between them. However the derived class acquires all the properties of both the class.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 22.
What is the difference between public and private visibility mode?
Answer:
When a base class is inherited with public visibility mode, the protected members of the base class will be inherited as protected members of the derived class and the public members of the base class will be inherited as public members of the derived class.
When a base class is inherited with private visibility mode the public and protected members of the base class become ‘private’ members of the derived class.

Question 23.
What are the points to be noted while deriving a new class?
Answer:
(i) The keyword class has to be used.
(ii) The name of the derived class is to be given after the keyword class.
(iii) A single colon
(iv) The type of derivation (the visibility mode), namely private* public or protected. If no visibility mode is specified, then by default the visibility mode is considered as private.
(v) The names of all base classes (parent classes) separated by comma.
class derived_class_
name:visibility_mode base_ class_name
{
// members of derivedclass
};

Question 24.
What is difference between the members present in the private visibility mode and the members present in the public visibility mode?
Answer:
When a base class is inherited with public visibility mode, the protected members of the base class will be inherited as protected members of the derived class and the public members of the base class will be inherited as public members of the derived class.
When a base class is inherited with private visibility mode the public and protected members of the base class become ‘private’ members of the derived class.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 25.
What is the difference between polymorphism and inheritance though are used for reusability of code?
Answer:
Polymorphism:
Allows object to decide which Inheritance: Allows a derived class to use the elements and methods defined in the base class. The derived class does not need to define those elements or methods in it again. So it increases the code reusability and hence reduces the length of the code.

Inheritance:
Allows a derived class to use the elements and methods defined in the base class. The derived class does not need to define those elements or methods in it again. So it increases the code reusability and hence reduces the length of the code.

Question 26.
What do you mean by overriding?
Answer:
When a derived class member function has the same name as that of its base class member function, the derived class member function shadows/hides the base class’s inherited function. This situation is called function overriding and this can be resolved by giving the base class name followed by :: and the member function name.

Question 27.
Write some facts about the execution of constructors and destructors in inheritance.
Answer:
(i) Base class constructors are executed first, before the derived class constructors execution.
(ii) Derived class cannot inherit the base class constructor but it can call the base class constructor by using,
Base_case name: :base_class_constructor() in derived class definition.
(iii) If there are multiple base classes, then it starts executing from the left most base class.
(iv) In multilevel inheritance, the constructors will be executed in the order of inheritance.
(v) Destructors are executed in the reverse order of inheritance.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 28.
Explain the different types of inheritance.
Answer:
There are different types of inheritance viz., Single inheritance, Multiple inheritance, Multilevel
inheritance, Hybrid inheritance and Hierarchical inheritance.
(i) Single Inheritance:
When a derived class inherits only from one base class, it is known as single inheritance.

(ii) Multiple Inheritance:
When a derived class inherits from multiple base classes it is known as multiple inheritance.

(iii) Hierarchical inheritance:
When more than one derived classes are created from a single base class, it is known as Hierarchical inheritance.

(iv) Multilevel Inheritance:
The transitive nature of inheritance is itself reflected by this form of inheritance. When a class is derived from a class which is a derived class – then it is referred to as multilevel inheritance.

(iv) Hybrid inheritance:
When there is a combination of more than one type of inheritance, it is known as hybrid inheritance. Hence, it may be a combination of Multilevel and Multiple inheritance or Hierarchical and Multilevel inheritance or Hierarchical, Multilevel and Multiple inheritance.

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance 10

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 29.
Explain the different visibility mode through pictorial representation.
Answer:
An important feature of Inheritance is to know which member of the base class will be acquired by the derived class. This is done by using visibility modes. The accessibility of base class by the derived class is controlled by visibility modes. The three visibility modes are private, protected and public. The default visibility mode is private. Though visibility modes and access specifiers look similar, the main difference between them is Access specifiers control the accessibility of the members with in the class where as visibility modes control the access of inherited members with in the class.

Private visibility mode:
When a base class is inherited with private visibility mode, the public and protected members of the base class become ‘private’ members of the derived class.

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance 11

Protected visibility mode:
When a base class is inherited with protected visibility mode the protected and public members of the base class become ‘protected members’ of the derived class.

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance 12

Public visibility mode:
When a base class is inherited with public visibility mode, the protected members of the base class will be inherited as protected members of the derived class and the public members of the base class will be inherited as public members of the derived class.

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance 13

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 30.
#include<iostream>
#include<string.h>
#include<stdio.h>
using name spacestd;
class publisher
{
char pname[15];
char hoffice[15];
char address[25];
double turnover;
protected:
char phone[3][10];
void register( );
public:
publisher( );
~publisher( );
void enter data( );
void disp data( );
};
class branch
class author: public branch, publisher
{
intaut_code;
charaname[20];
float income;
public:
author( );
~author( );
voidgetdata( );
voidputdata( );
};
Answer the following questions based on the above given program:
3.1 Which type of Inheritance is shown in the program?
3.2 Specify the visibility mode of base classes.
3.3 Give the sequence of Constructor/ Destructor Invocation when object of class author is created.
3.4 Name the base class(/es) and derived class (/es).
3.5 Give number of bytes to be occupied by the object of the following class:
(i) publisher
(ii) branch
(iii) author
3.6 Write the names of data members accessible from the object of class author.
3.7 Write the names of all member functions accessible from the object of class author.
3.8 Write the names of all members accessible from member functions of class author.
Answer:
3.1. Multiple Inheritance
3.2. Visibility mode publishes and Branch is public.

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance 14

3.3.
publisher ( )
branch ( )
author ( )
~ author ( )
~ branch ( )
~ publisher ( )

3.4
Base classes: publisher, branch
Derived class: author

3.5
(i) publisher

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance 15

(ii) branch

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance 16

(iii) author

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance 17

3.6. DataMember

publisher::phone[3] [10]
branch::bphone[2][10]
branch::no_of_emp
author::aut_code
author::name[20]
author::income

3.7. Member functions
publisher::register( )
publisher::enterdata( )
publisher::dispdata( )
branch::havedata( )
branch::givedata( )
author::getdata( )
author::putdata( )

3.8

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance 18

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 31.
Consider the following C++ code and answer the questions.
class Personal
{
int Class,Rno;
char Section;
protected:
char Name[20];
public: personal( );
void pentry( );
void Pdisplay( );
};
class Marks:private Personal
{
float M{5};
protected:
char Grade[5];
public:
Marks( );
void M_entry( );
void M_display( );
};
class Result:
public Marks
{
float Total, Agg;
public:
char FinalGrade, Commence[20];
Result( );
void R_calculate( ) ;
void R_display( );
}:
4.1 Which type of Inheritance is shown in the program?
4.2 Specify the visibility mode of base classes.
4.3 Give the sequence of Constructor/ Destructor Invocation when object of class Result is created.
4.4 Name the base class(/es) and derived class (/es).
4.5 Give number of bytes to be occupied by the object of the following class:
(i) Personal (ii) Marks (iii) Result
4.6 Write the names of data members accessible from the object of class Result.
4.7 Write the names of all member functions accessible from the object of class Result.
4.8 Write the names of all members accessible from member functions of class Result.
Answer:
4.1. Multilevel Inheritance
4.2. Private for Personal Public for marks
4.3.
constructors
Personal( )
Marks( )
Result( )
Default destructors are executed
4.4.
Base class: Personal
Derived class: Marks, Result
4.5.
(i) Personal

TN State Board 11th Computer Science Important Questions Chapter 14 Classes and Objects 1

(ii) Marks

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance 20

(iii) Result

TN State Board 11th Computer Science Important Questions Chapter 16 Inheritance 21

4.6
Result::Total
Result::Agg
Marks::Grade[5]

4.7.
Rcalculate( )
RDisplay( )
Mentry( )
Mdisplay( )

4.8

DataMembers

Member functions

Result: :Total Result: :Rcalculate( )
Result:: Agg Result: :RDisplay( )
Marks::Grade[5] Marks::Mentry( )
Result::FinalGrade Marks:: Mdisplay( )
Result::Commence[20]

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 32.
Write the output of the following program.
#include<iostream>
using namespace std;
class A
{
protected:
int x;
public:
void show( )
{
cout<<“x =”<<x<<endl;
}
A( )
{
cout<<endl<<“l am class A”<<endl;
}
~A( )
{
cout<<endl<<“Bye”;
}
};
class B:
public A
{
{
protected:
int y;
public:
B(int x, int y)
{
this→x = x; //this → is used to denote the objects datamember
this->y = y; //this → is used to denote the objects datamember
}
B( )
{
cout<<endl<<“l am class B”<<endl;
}
~B( )
{
cout<<endl<<“Bye”;
}
void show ( )
{
cout<<“x=” <<x<<endl;
cout«”y=”<<y<<endl;
}
};
int main( )
{
A objA;
B objB(30, 20);
objB.show( );
}
return 0;
}
Answer:
Output:
I am class A
I am class A
x = 30
y = 20
Bye
Bye
Bye

Question 33.
Debug the following program.
Output
————
15
14
13
Program :
————
%include(iostream.h)
#include<conio.h>
Class A
{
public;
int a1,a2:a3;
Void getdata[ ]
{
a1=15;
a2=13;
a3=13;
}
}
Class B:: public A( )
{
PUBLIC
voidfunc( )
{
int b1:b2:b3;
A::getdata[ ];
b1=a1;
b2=a2;
a3=a3;
cout<<bl<<‘\t'<<b2<<‘t\'<<b3;
}
void main( )
{
clrscr( )
B der;
derl:func( );
getch( );
}
Answer:
#include<iostream>
#include<conio.h>
using namespace std;
class A
{
public:
int a1,a2,a3;
void getdata( )
{
a1=15;
a2=14;
a3=13;
}
classBrpublic A
{
public:
void function ( )
{
int b1,b2,b3;
A: :getdata( );
b1=a1;
b2=a2;
b3=a3;
cout<<b1<<“\n”<<b2<<“\n”<<b3;
}
};
int main ( )
{
B der;
der.func( )
return 0;
}

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Choose the correct answer:

Question 1.
The most important features of OOP is:
(a) Encapsulation
(b) Abstraction
(c) Polymorphism
(d) Inheritance
Answer:
(d) Inheritance

Question 2.
A class that inherits from a superclass is called a:
(a) super class
(b) derived class
(c) abstract class
(d) finite class
Answer:
(b) derived class

Question 3.
_________ allows us to inherit all the code of one class to another class.
(a) Inheritance
(b) Polymorphism
(c) Data hiding
(d) Overloading
Answer:
(a) Inheritance

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 4.
The class to be inherited is called ______ class.
(a) base
(b) sub
(c) abstract
(d) normal
Answer:
(a) base

Question 5.
When a derived class inherits only from one base class, it is known as ______ inheritance.
(a) Single
(b) Multiple
(c) Multilevel
(d) Hybrid
Answer:
(a) Single

Question 6.
The _________ class is a power packed class, as it can add additional attributes and methods.
(a) derived
(b) base
(c) first
(d) last
Answer:
(a) derived

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 7.
When a derived class inherits from multiple base classes it is known as _________ inheritance.
(a) Multiple
(b) Multilevel
(c) Hybrid
(d) Single
Answer:
(a) Multiple

Question 8.
When more than one derived classes are created from a single base class, it is known as _________ inheritance.
(a) One
(b) Common
(c) Hybrid
(d) Hierarchical
Answer:
(d) Hierarchical

Question 9.
When there is a combination of more than one type of inheritance, it is known as _________ inheritance.
(a) Hybrid
(b) Multiple
(c) Multilevel
(d) Single
Answer:
(a) Hybrid

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 10.
While defining a derived class, the ______ class should identify the class from which it is derived.
(a) abstract
(b) common
(c) proper
(d) derived
Answer:
(d) derived

Question 11.
The name of the derived class is to be given after the keyword:
(a) function
(b) variables
(c) class
(d) object
Answer:
(c) class

Question 12.
A __________ is used between base class and derived class.
(a) ,
(b) :
(c) ;
(d) ::
Answer:
(b) :

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 13.
The names of all base classes are separated by:
(a) comma
(b) colon
(c) semi-colon
(d) braces
Answer:
(a) comma

Question 14.
Though the derived class inherits all the members of base class, it has access privilege only to _________ members of the base class.
(a) private
(b) non-private
(c) finite
(d) visible
Answer:
(b) non-private

Question 15.
In _______ inheritance the level of inheritance can be extended to any number of level depending upon the relation.
(a) multiple
(b) single
(c) hybrid
(d) multilevel
Answer:
(d) multilevel

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 16.
The relation between grandfather, father and child is established in:
(a) polymorphism
(b) abstraction
(c) multilevel inheritance
(d) single inheritance
Answer:
(c) multilevel inheritance

Question 17.
A class without any declaration will have ______ byte size.
(a) 1
(b) 2
(c) 3
(d) 4
Answer:
(a) 1

Question 18.
In a class x{ }; X occupies byte.
(a) 2
(b) 4
(c) 3
(d) 1
Answer:
(d) 1

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 19.
The accessibility of base class by the derived class is controlled by ______ modes.
(a) visibility
(b) common
(c) derived
(d) base
Answer:
(a) visibility

Question 20.
There are ________ visibility modes.
(a) 4
(b) 3
(c) 2
(d) 5
Answer:
(b) 3

Question 21.
The default visibility mode is:
(a) auto
(b) static
(c) private
(d) protected
Answer:
(c) private

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 22.
When a base class is inherited with protected visibility mode the protected and public members of the base class become ________ members of the derived class.
(a) public
(b) protected
(c) private
(d) static
Answer:
(b) protected

Question 23.
When classes are inherited with public, protected or private, the private members of the base class are:
(a) inherited
(b) not inherited
(c) not visible
(d) none
Answer:
(b) not inherited

Question 24.
When you derive the class from an existing base class, it may inherit the properties of the base class based on its ________ mode.
(a) visibility
(b) static
(c) auto
(d) extern
Answer:
(a) visibility

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 25.
________ inheritance should be used when you want the features of the base class to be available to the derived class but not to the classes that are derived from the derived class.
(a) Private
(b) Public
(c) Protected
(d) Single
Answer:
(a) Private

Question 26.
________ inheritance should be used when features of base class to be available only to the derived class members but not to the outside world.
(a) Unprotected
(b) Protected
(c) Private
(d) Multiple
Answer:
(b) Protected

Question 27.
________ inheritance can be used when features of base class to be available the derived class members and also to the outside world.
(a) Public
(b) Multilevel
(c) Single
(d) Protected
Answer:
(a) Public

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 28.
The _______ are executed in the reverse order.
(a) constructors
(b) derived class
(c) base class
(d) destructors
Answer:
(d) destructors

Question 29.
Base class constructors are executed _______ before the derived class constructors execution.
(a) first
(b) middle
(c) last
(d) none
Answer:
(a) first

Question 30.
Derived class _______ the base class constructor but it can call the base class constructor.
(a) can inherit
(b) cannot inherit
(c) cannot call
(d) none
Answer:
(b) cannot inherit

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 31.
If there are multiple base classes, then its start executing from the _______ most base class.
(a) left
(b) top
(c) right
(d) bottom
Answer:
(a) left

Question 32.
In _______ inheritance, the constructors will be executed in the order of inheritance.
(a) single
(b) multilevel
(c) hybrid
(d) hierarchical
Answer:
(b) multilevel

Question 33.
Derived class can call the base class constructor by using:
(a) :
(b) .
(c) ;
(d) ::
Answer:
(d) ::

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 34.
size of derived class object = _______ + size of all data members in derived class.
(a) size of all base class data members
(b) size of only public base class data members
(c) size of only private base class data members
(d) size of only protected base class data members
Answer:
(a) size of all base class data members

Question 35.
The public members can be accessed by the object of the derived class similar to its own members in:
(a) public
(b) auto
(c) static
(d) protected
Answer:
(a) public

Question 36.
In inheritance the _________ have higher priority.
(a) base class member function
(b) derived class member function
(c) constructor member function
(d) destructor member function
Answer:
(b) derived class member function

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 37.
Shadowing base class function in derived class can be resolved using:
(a) ::
(b) :
(c) ,
(d) <
Answer:
(a) ::

Question 38.
_________ pointer is a constant pointer that holds the memory address of the current object.
(a) this
(b) for
(c) if
(d) else
Answer:
(a) this

Question 39.
In case of inheritance where both base and derived class are having constructors, when an object of derived class is created then:
(a) constructor of derived class will be invoked first.
(b) constructor of base class will be invoked first.
(c) constructor of derived class will be executed first followed by base class.
(d) constructor of base class will be executed first followed by derived class.
Answer:
(d) constructor of base class will be executed first followed by derived class.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 40.
In case of inheritance where both base and derived class are having constructor and destructor, then which of the following are true?
(i) Constructors are executed in their order of derivation.
(ii) Constructors are executed in reverse order of derivation.
(iii) Destructors are executed in their order of derivation.
(iv) Destructors are executed in reverse order of derivation.
(a) Only (ii), (iv)
(b) Only (i), (iii)
(c) Only (i), (iv)
(d) Only (ii), (iii)
Answer:
(c) Only (i), (iv)

Question 41.
class x, class y and class z are derived from class BASE. This is _______ inheritance.
(a) Multiple
(b) Multilevel
(c) Hierarchical
(d) Single
Answer:
(c) Hierarchical

Question 42.
The _____ inherits some or all of the properties of the class.
(a) base, derived
(b) derived, base
(c) derived, initial
(d) base, final
Answer:
(b) derived, base

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 43.
State whether the following statements about inheritance are true or false.
(i) A public member of a class can be accessed by its own objects using the dot operator.
(ii) While inheriting, the private members of the base class will never become the members of its derived class.
(a) true, false
(b) false, true
(c) true, true
(d) false, false
Answer:
(c) true, true

Question 44.
In C++ program, Inheritance allows:
(a) Class Re-usability
(b) Creating a hierarchy of classes
(c) Extendibility
(d) All
Answer:
(d) All

Question 45.
Match the following:

(i) Single Inheritance  (a) combination of more than one type of Inheritance
(ii) Hierarchical Inheritance  (b) Inherits only from one base class
(iii) Multilevel Inheritance  (c) More than one derived classes are created.
(iv) Hybrid Inheritance  (d) Transitive nature of inheritance.

(a) (i) – (b); (ii) – (c); (iii) – (d); (iv) – (a)
(b) (i) – (c); (ii) – (d); (iii) – (a); (iv) – (b)
(c) (i) – (d); (ii) – (a); (iii) – (b); (iv) – (c)
(d) (i) – (c); (ii) – (d); (iii) – (b); (iv) – (a)
Answer:
(a) (i) – (b); (ii) – (c); (iii) – (d); (iv) – (a)

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 46.
Assertion (A):
The accessibility of base class by the derived class is controlled by visibility modes.
Reason (R):
The default visibility mode is public.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true, but R is not the correct explanation for A.
(c) A is true, but R is false.
(d) A is false, but R is true.
Answer:
(c) A is true, but R is false.

Question 47.
Which of the following is the process of creating new classes from an existing class?
(a) Polymorphism
(b) Inheritance
(c) Encapsulation
(d) Super class
Answer:
(b) Inheritance

Question 48.
Which of the following derives a class student from the base class school?
(a) school: student
(b) class student: public school
(c) student: public school
(d) class school: public student
Answer:
(b) class student: public school

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 49.
The type of inheritance that reflects the transitive nature is:
(a) Single Inheritance
(b) Multiple Inheritance
(c) Multilevel Inheritance
(d) Hybrid Inheritance
Answer:
(c) Multilevel Inheritance

Question 50.
Which visibility mode should be used when you want the features of the base class to be available to the derived class but not to the classes that are derived from the derived class?
(a) Private
(b) Public
(c) Protected
(d) All of these
Answer:
(a) Private

Question 51.
Inheritance is process of creating new class from:
(a) base class
(b) abstract
(c) derived class
(d) function
Answer:
(a) base class

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 52.
A class is derived from a class which is a derived class itself, then this is referred to as:
(a) multiple inheritance
(b) multilevel inheritance
(c) single inheritance
(d) double inheritance
Answer:
(b) multilevel inheritance

Question 53.
Which amongst the following is executed the order of inheritance?
(a) Destructor
(b) Member function
(c) Constructor
(d) Object
Answer:
(c) Constructor

Question 54.
Which of the following is true with respect to inheritance?
(a) Private members of base class are inherited to the derived class with private.
(b) Private members of base class are not inherited to the derived class with private accessibility.
(c) Public members of base class are inherited but not visible to the derived class.
(d) Protected members of base class are inherited but not visible to the outside class.
Answer:
(c) Public members of base class are inherited but not visible to the derived class.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 55.
Based on the following class declaration answer the questions (from 55.1 to 55.4).
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( );
};
};

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 55.1.
Which is the base class of the class heavyvehicle?
(a) bus
(b) heavyvehicle
(c) vehicle
(d) both (a) and (c)
Answer:
(c) vehicle

Question 55.2.
The data member that can be accessed from the function displaydataQ.
(a) passenger
(b) load
(c) ticket
(d) all of these
Answer:
(d) all of these

Question 55.3.
The member function that can be accessed by an objects of bus Class is:
(a) input_data( ),
(b) read_data( ),output_data( )write_data( )
(c) fetch_data( )
(d) all of these display_data( )
Answer:
(d) all of these display_data( )

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance

Question 55.4
The member function that is inherited as public by Class Bus:
(a) input_data( ),
(b) read_data( ), output_data( )write_data( )
(c) fetch_data( )
(d) all of these display_data( )
Answer:
(d) all of these display_data( )

Question 56.
class x
{
int a;
public :
x( )
{ }
};
class y
{ x x1;
public :
y( )
{ }
};
class z : public y,x
{
int b;
public:
z( )
{ }
} z1;

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 16 Inheritance
What is the order of constructor for object z1 to be invoked?
(a) z,y,x,x
(b) x,y,z,x
(c) y,x,x,z
(d) x,y,z
Answer:
(d) x,y,z

TN Board 11th Computer Science Important Questions