Get the most accurate NCERT Solutions for Class 12 Computer Science Inheritance here. Updated for the 2025-26 academic session, these solutions are based on the latest NCERT textbooks for Class 12 Computer Science. Our expert-created answers for Class 12 Computer Science are available for free download in PDF format.
Detailed Inheritance NCERT Solutions for Class 12 Computer Science
For Class 12 students, solving NCERT textbook questions is the most effective way to build a strong conceptual foundation. Our Class 12 Computer Science solutions follow a detailed, step-by-step approach to ensure you understand the logic behind every answer. Practicing these Inheritance solutions will improve your exam performance.
Class 12 Computer Science Inheritance NCERT Solutions PDF
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

(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

(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()
| NCERT Solutions Class 12 Computer Science Boolean Algebra |
| NCERT Solutions Class 12 Computer Science C++ Revision Tour |
| NCERT Solutions Class 12 Computer Science Chapter 3 Stack |
| NCERT Solutions Class 12 Computer Science Chapter 4 Queue |
| NCERT Solutions Class 12 Computer Science Chapter 8 Database Concepts |
| NCERT Solutions Class 12 Computer Science Chapter 9 Structured Query Language |
| NCERT Solutions Class 12 Computer Science Constructor and Destructor |
| NCERT Solutions Class 12 Computer Science Data File Handling |
| NCERT Solutions Class 12 Computer Science Implementation of OOP Concepts in C++ |
| NCERT Solutions Class 12 Computer Science Networking and Open Source Concepts |
| NCERT Solutions Class 12 Computer Science Object Oriented Programming in C++ |
Important Practice Resources for Class 12 Computer Science
NCERT Solutions Class 12 Computer Science Inheritance
Students can now access the NCERT Solutions for Inheritance prepared by teachers on our website. These solutions cover all questions in exercise in your Class 12 Computer Science textbook. Each answer is updated based on the current academic session as per the latest NCERT syllabus.
Detailed Explanations for Inheritance
Our expert teachers have provided step-by-step explanations for all the difficult questions in the Class 12 Computer Science chapter. Along with the final answers, we have also explained the concept behind it to help you build stronger understanding of each topic. This will be really helpful for Class 12 students who want to understand both theoretical and practical questions. By studying these NCERT Questions and Answers your basic concepts will improve a lot.
Benefits of using Computer Science Class 12 Solved Papers
Using our Computer Science solutions regularly students will be able to improve their logical thinking and problem-solving speed. These Class 12 solutions are a guide for self-study and homework assistance. Along with the chapter-wise solutions, you should also refer to our Revision Notes and Sample Papers for Inheritance to get a complete preparation experience.
The complete and updated is available for free on StudiesToday.com. These solutions for Class 12 Computer Science are as per latest NCERT curriculum.
Yes, our experts have revised the as per 2026 exam pattern. All textbook exercises have been solved and have added explanation about how the Computer Science concepts are applied in case-study and assertion-reasoning questions.
Toppers recommend using NCERT language because NCERT marking schemes are strictly based on textbook definitions. Our will help students to get full marks in the theory paper.
Yes, we provide bilingual support for Class 12 Computer Science. You can access in both English and Hindi medium.
Yes, you can download the entire in printable PDF format for offline study on any device.