NCERT Solutions Class 12 Computer Science Inheritance

NCERT Solutions Class 12 Computer Science Inheritance have been provided below and is also available in Pdf for free download. The NCERT solutions for Class 12 Computer Science have been prepared as per the latest syllabus, NCERT books and examination pattern suggested in Class 12 by CBSE, NCERT and KVS. Questions given in NCERT book for Class 12 Computer Science are an important part of exams for Class 12 Computer Science and if answered properly can help you to get higher marks. Refer to more Chapter-wise answers for NCERT Class 12 Computer Science and also download more latest study material for all subjects. Inheritance is an important topic in Class 12, please refer to answers provided below to help you score better in exams

Inheritance Class 12 Computer Science NCERT Solutions

Class 12 Computer Science students should refer to the following NCERT questions with answers for Inheritance in Class 12. These NCERT Solutions with answers for Class 12 Computer Science will come in exams and help you to score good marks

Inheritance NCERT Solutions Class 12 Computer Science


Question 1: Answer the questions (i) to (iv) based on the following:
class ITEM

{
int ID;
char IName[20];
protected:
float Qty;
public:
ITEM();
void Enter();
void View();
};
Class TRADER;
{
int DCode;
Protected:
char Manager[20];
public:
TRADER();
void Enter();
void View();
};
class- SALEPOINT : public ITEM, private TRADER
{
Char Name[20],Location[20];
public:
SALEPOINT();
void EnterAll();
void ViewAll();
};

(i) Which type of Inheritance out of the following is illustrated in the above example?
- Single Level Inheritance
- Multi Level Inheritance
- Multiple Inheritance
(ii) Write the names of all the data members, which are directly accessible from the member functions of class SALEPOINT.
(iii) Write the names of all the member functions, which are directly accessible by an object of class SALEPOINT.
(iv) What will be the order of execution of the constructors, when an object of class SALEPOINT is declared?
Аnswer:
1. Multiple Inheritance
2. Name, Location, Manager, Qty
3. EnterAll ( ) , VeiwAll ( ) , Enter ( ) ,ViewO
4. ITEM ( ) , TRADER (), SALEPOINT ()

Question 2: Give the following class definition answer the question that is follow :
class University
{
char name[20];
protected:
char vc[20];
public :
void estd();
void inputdata();
void outputdata();
}
class College : protected University
{
int regno;
protected
char principal()
public :
int no_of_students;
void readdata();
void dispdata();
};
class Department : public College
char name[20];
char HOD[20];
public:
void fetchdata(int);
void displaydata();
}

(i) Name the base class and derived class of college.
Answer:
Base class : University
Derived class : Department

(ii) Name the data member(s) that can be accessed from function display data.
Answer: char name [20], char principal), no_of_students, char vc[20]

(iii) What type of inheritance is depicted in the above class definition ?
Answer: Multilevel Inheritance

(iv) What will be the size of an object (in bytes) of class Department ?
Answer: 85 bytes.

Question 3: Answer the question (i) to (iv) based on the following :
class Exterior
{
int orderld;
char Address[20];
protected:
float Advance;
public:
Exterior();
void Book();
void View();
};
class Paint : public Exterior
{
int Wall Area, ColorCode;
protected:
char Type;
public:
paint();
void PBook();
void PView()
};
class Bill : public Paint
{
float Charges;
void Calculate();
public:
Bill();
void Billing();
void Print();
};
(i)Which type of Inheritance out of the following is illustrated in the above example?
— Single Level Inheritance
— Multi Level Inheritance
— Multiple Inheritance
Answer: Multi Level Inheritance

(ii) Write the names of all the data members, which are directly accessible from the member functions of class Paint.
Answer: Wall Area, Color Code, Type, Advance
Note : No marks to be awarded for any partial/ additional answer(s)

(iii) Write the names of all the member functions, which are directly accessible from an object of class Bill.
Answer:
Billing( ), Print( ), PBook( ), PView( ), Book( ), View( )
Note :
• No marks to be awarded for any partial/ additional answer(s)
• Constructors can be ignored

(iv) What will be the order of execution of the constructors, when an object of class Bill is declared ?
Answer:
Exterior(), Paint (), Bill()
Note : No marks to be awarded for any other order

Question 4: Write the definition of a class Photo in C + + with following description :
Private Members
— Pno // Data member for Picture Number (an integer)
— Category // Data member for Picture Category (a string)
— Exhibit // Data member for Exhibition Location (a string)
— Fix Exhibit // A member function to assign
//Exhibition Location as per category
//as shown in the following table
Category    Exhibit
Antique      Zaveri
Modern      Johnsen
Classic       Terenida
Public        Members
— Enter ( ) //A function to allow user to enter values //Pno, category and call FixLocation () function
— SeeAll ( ) //A function to display all the data members
Answer:
class photo
{
int Pno;
char Category [20]; char Exhibit [20]; void FixExhibit (); public :
void Register();
void ViewAll();
};
void Photo :: FixExhibit()
{
if(strcmpi(category, "Antique") == 0)
strcpy(Exhibit, "Zaveri");
else if(strcmpi(Category,"Modern") == 0)
strcpy (Exhibit, "Johnsen");
else if strcmpi(Category,"Classic") == 0)
strcpy(Exhibit, "Terenida");
}
void Photo :: Register()
{
cin>>"Pno";
gets(Category);
FixExhibit 0;
}
void Photo :: ViewAll()
{
coute<Pno<<Category<<Exhibit<<endl;
}

Question 5: Answer the question (i) to (iv) based on the following :
class Interior
{
int OrderId;
char Address[20];
protected:
float Advance;
public:
Interior();
void Book();
void View();
};

class Painting : public Interior
{
int WallArea, ColorCode;
protected:
char Type;
public:
Painting();
void PBook();
void PView();
};
class Billing : public Painting
{
float Charges;
void Calculate();
public:
Billing();
void Bill();
void BillPrint();
};

(i) Which type of Inheritance of the following is illustrated in the above example ?
— Single Level Inheritance
— Multi Level Inheritance
— Multiple Inheritance
Answer: Mutli Level Inheritance
(ii) Write the names of all the data members, which are directly accessible from the member functions of class painting.
Wall Area, Color Code, Type, Advance
Note :
• No marks to be awarded for any partial or additional answer(s)
(iii) Write the names of all the member functions, which are directly accessible from an
object of class Billing. Bill(), BillPrint(), PBook(), PViewQ, Book(), View()
Note : No marks to be awarded for any partial/ additional answer(s)
• Constructors can be ignored
(iv) What will be the order of execution of the constructors, when an object of class Billing is declared ?
Answer: Interior, Painting, Billing
Note : No marks to be awarded for any other order

Question 6: Answer the questions (i) to (iv) based on the following code :
class AC
{

char Model[10];
char Date_of_purchase[10];
char Company[20];
public();
AC();
void enter car detail();
void show car detail();
};
class Accessories : protected AC
{
protected:
char Stabilizer[30];
char AC_cover[20];
public:
float Price;
Accessories();
void enteraccessoriesdetails();
void showaccessoriesdetails();
};
class Dealer : public Accessories
{
int No_of_dealers;
char dealers_name[20];
int No_of_products;
public:
Dealer();
void enterdetails();
void showdetails();
};

(i) How many bytes will be required by an object of class Dealer and class Accessories?
(ii) Which type of inheritance is illustrated in the above c++ code ? Write the base class and derived class name of class Accessories.
(iii)Write names of all the members which are accessible from the objects of class Dealer.
(iv)Write names of all the members accessible from member functions of class Dealer.
Answer:
(i) Object of Dealer = 118 bytes and object of Accessories = 98 bytes
(ii) Multilevel Inheritance, Base class = AC,Derived class = Dealer
(iii) enterdetails(), showdetails(), price, enteraccessoriesdetails(), showaccessoriesdetails()
(iv) No_of_dealers, dealers name, No_of_products, enterdetails(), showdetails(), Stablizer,
Ac_cover, price, enteraccessories details(), showaccessoriesdetails(), entercardetail,showcardetail()

Question 7: Consider the following class state :
class State
{
protected:
int tp; //no. of tourist places
public:
State()
{
tp = 0;
}
void inctp()
{
tp++;
}
int gettp()
{
return tp;
}
};

Write a code in C + + to publically derive another class 'District' with the following additional members derived in the Public visibility mode.
Data Members
distname - char(50)
population - long
Member functions:
dinput() - To enter distname and population.
doutput() - To display distname and population on screen.
Аnswer:
class District : public state
{
private:
char *distname[50];
long population;
public :
void dinput()
{
gets(distname);
cin>>population;
}
void output()
{
puts(disname);
cout>>population ;
}
}

Question 8: Define a class Dance Academy in C++ with following description :
Private Members :
• Enrollno of type int
• Name of type string
• Style of type string
• Fee of type float
• A member function chkfee( ) to assign the value of fee variable according to the style entered by the user according to the criteria as given below.
Style           Fee
Classical      10000
Western       8000
Freestyle     11000
Public Members
• A function enrollment) to allow users to enter values for Enroll no, Name, Style and call function chkfee( ) to assign value of fee variable according to the Style entered by the user.
• A function display( ) to allow users to view the details of all the data members.
Аnswer:
class Dance Academy
int Enrollno;
char Name[20];
Char, style[20-]
Float Fee;
void chkfee()
{
if(strcmpi(Style."Classical")==0)
Fee=10000;
else if(strcrapi(Style,"Western")==0)
Fee=8000;
else if(strcmpi(Style,"Freestyle")==0)
Fee=11000;
}
public;
void enrollment()
{
cout<<"Please enter Enrollno,Name,Style";
cin>>Enrollno;
gets(Name);
gets(Style);

chkfee();
}
void display()
{
cout<<"\n Entered Enrollno, Name Style, and Fee
is:"<<Enrollno<<"t"<<Name<<"\t"<<Style<<"\t"<<Fee;
}
};

Question 9: Consider the following C++ code and answer the questions from (i) to (iv) :
Class Campus
{
long Id;
char City[20];
protected:
char Country[20];
public:
Campus();
void Register();
void Display();
};
class Dept:private Campus
{
long DCode[10];
char HOD[20];
protected:
double Budget;
public:
Dept();
void Enter();
void Show();
};
class Applicant:public Dept
{
long RegNo;
char Name[20];
public:
Applicant();
void Enroll();
void View();
};

(i) Which type of Inheritance is shown in the above example?
(ii) Write the names of those member functions, which are directly accessed from the objects of class Applicant.
(iii) Write the names of those data members, which can be directly accessible from the member functions of class Applicant.
(iv) Is it possible to directly call function Display() of class University from an object of class Dept?
(Answer as Yes or No).
Аnswer:
(i) Multilevel Inheritance
(ii) Enroll(), View(), Enter(), Show().
(iii) RegNo., Name, Budget.
(iv) No.

Question 10: Consider the following and answer the question given below:
class ITEM
{
char ICode[10];
protected:
char IName[20];
public:
ITEM();
void Enter():
void Display();
};
class SUPPLIER
{
char SCode [10];
protected:
char SName[25];
public :
SUPPLIER();
void TEnter();
void TDisplay();
};
class SHOP: private SUPPLIER, public ITEM
{
char SHOPADDRESS [15], SEmail [25];
public:
SHOP();
void Enter();
void Display();
};

(i) Which type of inheritance is shown in the above example?
(ii)Write the names of all the member functions accessible from Enter() function of class SHOP.
(iii)Write name of all the member functions accessible through an object of class SHOE
(iv)What will be the order of execution for the constructors ITEM(), SUPPLIER() and SHOP(),when an object of class SHOP is declared?
Answer:
(i) Multiple inheritance.
(ii) Display (), TEnter(), TDisplay, Enter(), DisplayO.
(iii) Enter(), DisplayO, ITEM.Enter(), Item. Display.
(iv) ITEM(), then SUPPLIER(), then SHOP().

Question 11: Consider the following C++ code and answer the questions from (i) to (iv) :
class Personal:
{
int Class, Rno; char Section; protected:
char Name[20];
public:
Personal();
void Pentry();
void Pdisplayf();
};
class Marks:private Personal
{
float M[5];
protected:
char Grade[5];
public:
Marks();
void Mentry();
void Mdisplay();
};
class Result : public Marks
{
float Total, Agg;
public:
char FinalGrade,Comments[20];
Result();
void Rcalculate();
void Rdisplayt();
};

(i) Which type of inheritance is shown in the above example?
(ii) Write the names of those data members, which can be directly accessed from the objects of class result.
(iii) Write the names of those member functions, which can be directly accessed from the objects of class Result.
(iv) Write the names of those data members, which can be directly accessed from the Mentry() function of class Marks.
Аnswer:
1. Inheritance Type:
Personal Base class
  ↓
Marks Sub class of personal
  ↓
Result Sub class of Result
Multilevel Inheritance
2. FinalGrade
Comments [20]
3. Rcalculate ( )
Rdisplay ( )
Mentry ( )
Mdisplay ( )
4. M [5], Rno, Class, Section,
Grade [5]

Question 12: Consider the following C++ code and answer the questions from (i) to (iv):
class Student
{
int Class, Rno;
char Section;
protected :
char SName[20];
public:
Student();
void Stentry();
void StdisplayO;
};
class Score: private Student
{
float Marks[5];
protected:
char Grade[5];
public:
Score();
void Sentry();
void Sdisplay();
};
class Report : public Score
{
float Total, Avg;
public:
char OverallGrade, Remarks[20];
Report();
void Revaluate();
void RPrint();
};
(i) Which type of inheritance is shown in the above example?
(ii) Write the names of those data members, which can be directly accessed from the objects of class Report.
(iii) Write the names of those member function, which can be directly accessed from the objects of class Report.
(iv) Write the names of those data members, which can be directly accessed from the Sentry( ) function of class Score.
Аnswer:
1. Student
  ↓
Score
  ↓
Report
This is multilevel inheritance:
2. Data Members:
Total,
Avg,
OverallGrade,
Remarks [20],
3. Member functions:
Report ( ),
REvaluate ( ),
RPrint ( ),
Score ( ), .
Sentry ( ),
Sdisplay ( ).
4. Data members
Marks [5], Class, Rno, Section,
Grade [5], SName.

Question 13: Answer the questions (i) to (iv) based on the following:
class COMPANY
{
char Location[20];
double budget, income;
protected:
void Accounts();
public :
COMPANY();
void Register();
void Show();
};
class FACTORY : public COMPANY
{
char Location[20];
int Workers;
protected:double salary;
void Computer();
public:
FACTORY();
void Enter();
void Show();
};
class SHOP:private Company
{
char Location[20];
float Area;
double Sale;
public:
SHOP();
void Input();
void Output();
};

(i) Name the type of inheritance illustrated in the above C+ + code.
(ii) Write the name of data members which are accessible from the member functions of class SHOE
(iii) Write the name of member functions which are accessible from the objects of class FACTORY.
(iv) Write the name of data members which are accessible from the objects of class SHOE
Answer:
(i) Hierarchical Inheritance
NCERT-Solutions-Class-12-Computer-Science-Inheritance-1.png

(ii) None
(iii) Enter(), Show(), Register( ), Accounts company :: Show ().
(iv) Data Members: NONE

Question 14: Answer the questions (i) to (iv) based on the following:
class ORGANIZATION
{
char Address[20];
double budget, income;
protected:
void Compute();
public:
ORGANIZATION();
void Get();
void Show();
};
class WORKAREA : public ORGANIZATION
{
charAddress[20];
int staff;
protected:
double pay;
void Calculate();
public:
WORKAREA();
void Enter();
void Display();
};
class SHOWROOM:private
ORGANIZATION
{
char Address[20];
float Area;
double Sale;
public:
SHOWROOM();
void Enter();

void Show();
};

(i) Name the type of inheritance illustrated in the above C+ + code.
(ii) Write the name of data members which are accessible from the member functions of class SHOWROOM.
(iii) Write the name of member functions which are accessible from the objects of class WORKAREA.
(iv) Write the name of members which are accessible from the objects of class SHOWROOM.
Answer:
(i) Hierarchical Inheritance
NCERT-Solutions-Class-12-Computer-Science-Inheritance-2.png

(ii) Address, Area, Sale, Budget, Income.
(iii) Enter(), Display(), Get (), Show()
(iv) Data Members: NONE
Member Functions: Enter(), Show()

Question 15: Answer the questions (i) to (iv) based on the following:
class indoor_sports
{
int i_id;
char i_name[20];
char i_coach[20];
protected:
int i_rank,i_fee;
void get_ifee()
public: indoor_sports();
void iEntry();
void ishow();
};
class outdoor_sports
{
int o_id;
char o_name[20];
char o_coach[20];
protected;
int orank,ofee;
void get_ofee();
public;
outdoor_sports();

void oshow();
};
class sports:public indoor_sports, protected outdoor_sports
{
char rules [20];
public;
sports();
void registration();
void showdata();
};

(i) Name the type of inheritance illustrated in the above C+ + code.
(ii) Write the names of all the members, which are accessible from the objects belonging to class outdoor_sports.
(iii) Write the name of member functions which are accessible from the objects of class sports.
(iv) What will be the size of the object belonging to class indoor_sports?
Аnswer:
(i) Multiple Inheritance.
(ii) Data Member; None
Member Funcitons; oEntry(), oShow()
Note :
No marks to be awarded for any partial or additional answer (s)
(iii) registration(), showdat(), oEnty(), oShow(), get_ofee(), iEntryO, iShow(), get_ ifee() Note :
No marks to be awarded for any partial or additional answer (s)
(iv) 46 Bytes

Question 16: Write the definition of a class DISTRICT in C++ with following description :
Private Member
– Dcode
//Data member for code (an integer)
– DName
//Data member for Name (a string)
– DPop
//Data member for Population (a long int)
– Area
//Data member for Area Coverage
(a float)
– Density
//Data member for Population Density
(a float)
– DenCal()
//A member function to calculate //Density as Pop/Area
Public Members
– Input()
//A function to allow user to enter
values of
//Dcode, DName, DPop, Area and call
DenCal () //function
– ShowALL()
//A function to display all the data
members
//also display a message “Highly Populated Area”
//if the Density is more than 12000
Answer:
Class DISTRICT
{
int DCode;
char DName[20];
long int DPop;
Float Area;
Float Dens;
Void Dencal();
Public:
void Input();
void showALL();
};
void DISTICT::Input()
{
cin>>Dcode;
gets(DName);//OR cin>>Dname;
cin>>DPop;
cin>>Area;
Dencal();
}
void DISTRICT::ShowALL()
{
cout<<Dcode<<DName<<DPop<<Area<<Dens; //Ignore endl if(Dens>12000)cout<<"Highly
Populated Area";
\\Ignore endl
}
void DISTRICT::Dencal()
{
Dens=DPop/Area;
}

Question 17: Answer the questions (i) to (iv) based on the following :
class PACKAGE
{
int PCode;
char PDes[20];
protected:
float PQty;
public :
PACKAGE();
void In();
void DispO;
};
class TRANSPORT
{
int TCode;
protected:
char TName[20];
public:
TRANSPORT();
void Enter();
void Display();
};
class DELIVERY:public PACKAGE, private TRANSPORT
{
char Address[40],Date[12];
public:
DELIVERY();
void Input();
void Show();
}

(i) Which type of Inheritance out of the following illustrated in the above example?
• Single Level Inheritance
• Multi Level Inheritance
• Multiple Inheritance
(ii) Write the names of all the data members, which are directly accessible from the member functions of class DELIVERY.
(iii) Write the names of all the member functions, which are directly accessible by an object of class DELIVERY.
(iv) What will be the order of execution of the constructors, when and object of class DELIVERY is declared ?
Answer:
(i) Multiple Inheritance.
(ii) PQty, IName, Address, Date
(iii) Input(), show(), In(), Disp()
(iv) PACKAGE(), TRANSPORTO, DELIVERY()

More Study Material

NCERT Solutions Class 12 Computer Science Inheritance

NCERT Solutions Class 12 Computer Science Inheritance is available on our website www.studiestoday.com for free download in Pdf. You can read the solutions to all questions given in your Class 12 Computer Science textbook online or you can easily download them in pdf.

Inheritance Class 12 Computer Science NCERT Solutions

The Class 12 Computer Science NCERT Solutions Inheritance are designed in a way that will help to improve the overall understanding of students. The answers to each question in Inheritance of Computer Science Class 12 has been designed based on the latest syllabus released for the current year. We have also provided detailed explanations for all difficult topics in Inheritance Class 12 chapter of Computer Science so that it can be easier for students to understand all answers.

NCERT Solutions Inheritance Class 12 Computer Science

Class 12 Computer Science NCERT Solutions Inheritance is a really good source using which the students can get more marks in exams. The same questions will be coming in your Class 12 Computer Science exam. Learn the Inheritance questions and answers daily to get a higher score. Inheritance of your Computer Science textbook has a lot of questions at the end of chapter to test the students understanding of the concepts taught in the chapter. Students have to solve the questions and refer to the step-by-step solutions provided by Computer Science teachers on studiestoday to get better problem-solving skills.

Inheritance Class 12 NCERT Solution Computer Science

These solutions of Inheritance NCERT Questions given in your textbook for Class 12 Computer Science have been designed to help students understand the difficult topics of Computer Science in an easy manner. These will also help to build a strong foundation in the Computer Science. There is a combination of theoretical and practical questions relating to all chapters in Computer Science to check the overall learning of the students of Class 12.

Class 12 NCERT Solution Computer Science Inheritance

NCERT Solutions Class 12 Computer Science Inheritance detailed answers are given with the objective of helping students compare their answers with the example. NCERT solutions for Class 12 Computer Science provide a strong foundation for every chapter. They ensure a smooth and easy knowledge of Revision notes for Class 12 Computer Science. As suggested by the HRD ministry, they will perform a major role in JEE. Students can easily download these solutions and use them to prepare for upcoming exams and also go through the Question Papers for Class 12 Computer Science to clarify all doubts

Where can I download latest NCERT Solutions for Class 12 Computer Science Inheritance

You can download the NCERT Solutions for Class 12 Computer Science Inheritance for latest session from StudiesToday.com

Can I download the NCERT Solutions of Class 12 Computer Science Inheritance in Pdf

Yes, you can click on the link above and download NCERT Solutions in PDFs for Class 12 for Computer Science Inheritance

Are the Class 12 Computer Science Inheritance NCERT Solutions available for the latest session

Yes, the NCERT Solutions issued for Class 12 Computer Science Inheritance have been made available here for latest academic session

How can I download the Inheritance Class 12 Computer Science NCERT Solutions

You can easily access the links above and download the Inheritance Class 12 NCERT Solutions Computer Science for each chapter

Is there any charge for the NCERT Solutions for Class 12 Computer Science Inheritance

There is no charge for the NCERT Solutions for Class 12 Computer Science Inheritance you can download everything free

How can I improve my scores by reading NCERT Solutions in Class 12 Computer Science Inheritance

Regular revision of NCERT Solutions given on studiestoday for Class 12 subject Computer Science Inheritance can help you to score better marks in exams

Are there any websites that offer free NCERT solutions for Inheritance Class 12 Computer Science

Yes, studiestoday.com provides all latest NCERT Inheritance Class 12 Computer Science solutions based on the latest books for the current academic session

Can NCERT solutions for Class 12 Computer Science Inheritance be accessed on mobile devices

Yes, studiestoday provides NCERT solutions for Inheritance Class 12 Computer Science in mobile-friendly format and can be accessed on smartphones and tablets.

Are NCERT solutions for Class 12 Inheritance Computer Science available in multiple languages

Yes, NCERT solutions for Class 12 Inheritance Computer Science are available in multiple languages, including English, Hindi