• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • NCERT Solutions
    • NCERT Books Free Download
  • TS Grewal
    • TS Grewal Class 12 Accountancy Solutions
    • TS Grewal Class 11 Accountancy Solutions
  • CBSE Sample Papers
  • NCERT Exemplar Problems
  • English Grammar
    • Wordfeud Cheat
  • MCQ Questions

CBSE Tuts

CBSE Maths notes, CBSE physics notes, CBSE chemistry notes

Chapterwise Question Bank CBSE Class 12 Computer Science (C++) – Inheritance

Contents

  • 1  Chapterwise Question Bank CBSE Class 12 Computer Science (C++) – Inheritance
    • 1.1 Exam Practice
      • 1.1.1 Long Answer Type Questions [4 Marks]

 Chapterwise Question Bank CBSE Class 12 Computer Science (C++) – Inheritance

Exam Practice

Long Answer Type Questions [4 Marks]

Question 1:
Consider the following C++ code and answer the questions from (i) to (iv)    Delhi 2014

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 accessed 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).
Answer:

(i) Multilevel Inheritance.
(ii) Member functions directly accessible through the objects of class Applicant are:
Enroll(), View(), Enter(), Show().
(iii) Data members directly accessible to the member functions of class Applicant are:
RegNo, Name, Budget.
(iv) No, because in the given program there is no class named University.

Question 2:
Consider the following C++ code and answer the questions from (i) to (iv):    Delhi 2013

class Student 
{
int Class, Rno; 
char Section; 
protected:
char SName[20]; 
public:
Student(); 
void Stentry(); 
void Stdisplay();
};
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 Overall Grade, Remarks[20]; 
Report(); 
void REvaluate(); 
void RP<rint();
};

(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 functions, 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.
Answer:

(i) Multilevel Inheritance.
(ii) OverallGrade, Remarks[20].
(iii) REvaluate( ), RPrint( ), Sentry( ), Sdisplay( ).
(iv) Marks[5], Grade[5], SName[20].

Question 3:
Consider the following and answer the questions given below:    Delhi 2013C

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 SH0PADDRESS[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 SHOP.
(iv) What will be the order of execution for the constructors ITEM(), SUPPLIER() and SHOP(), when an object of class SHOP is declared?

Ans

(i) Multiple Inheritance.
(ii)  void Display( ) of class ITEM, void Enter ( ) of class ITEM, void Display( ) of class SHOP, void TEnter( ) of class SUPPLIER, void TDisplay( ) of class SUPPLIER.
(iii) void Display( ) of class SHOP, void Enter( ) of class SHOP, void Display! ) of class ITEM, void Enter( ) of class ITEM.
(iv) SUPPLIER(), ITEM( ) and SHOP( ).

Question 4:
Suppose we have following C++ program: HOTS

#include<iostream.h>
#include<conio.h> 
class A
{
public:
A()Icout<<"A"; }
~A() ( cout«"~A"; }
};
class B
{
public:
B() j cout«"B"; } 
~B() { cout<<"~B”;}
};
class C
{
public:
C(){cout<<"C";} 
~C() { cout<<"~C";} 
private:
B a ; A b;
};
class D
{
public:
D(){cout<<"D";}
~D() { cout<<”~D";}
};
class E : public C 
{
public:
E(){ cout<<"E";}
~E() { cout<<"~E"; }
private:
D d; B b;
}; 
void main()
{
E e;
cout<<endl; 
getch();
}

Assuming that the program compiles and runs correctly, what does it print out?
Ans

BACDBE
~E~B~D~C~A~B

Question 5:
Consider a class network of the following figure: HOTS
Chapterwise Question Bank CBSE Class 12 Computer Science (C++) - Inheritance
The class ‘master’ derives information from both account and admin classes which in turn derive information from the class person. Define all the four classes and write a program to create and display the information contained in master objects.
Ans

#include<iostream.h>
#include<stdio.h>
#include<conio. h> 
class person 
{
private:
int code; 
char name[10]; 
public:
void read()
{
cout<<"Enter the code 
cin>>code; 
cout<<"Enter name 
gets(name);
}
void display()
{
cout<<"\nThe code ”<<code; 
cout<<"\nThe name ";
puts(name);
}
};
class account : virtual public person
{
float pay; 
public:
void read_acc()
{
cout<<"Enter pay "; 
cin>>pay;
}
void display_acc()
{
cout<<''\nThe pay amount is "<<pay;
}
};
class admin : public person
{
private:
int experience; 
public:
void read_adm()
{
read();
cout<<"Enter the experience "; 
cin>>experience;
}
void display_adm()
{
display();
cout<<”The experience is "; 
cout<<experience;
}
};
class master : public account, public admin 
{
public:
void read_master()
{
read_acc(); 
read_adm();
}
void display_master()
{
display_acc(); 
display_adm();
}
};
void main()
{
master obj; 
obj.read_master(); 
obj.display_master(); 
getch();
}

Question 6:
Answer the questions (i) to (iv) based on the following code:    Delhi 2011C

class FRUIT 
{
int FID;
//Identification number 
char type[20]; 
protected:
char Description[20]; 
float Cost; 
public:
FRUIT();
void Set_values(); 
void Show_values();
};
class FRESH : public FRUIT
{
char color[10]; 
protected:
char Agent[20]; 
public:
FRESH( );
void Read_values(); 
void Display_values();
};
class DECORATIVE : protected FRUIT
{
float Dec_charges; 
public:
void input(); 
void output();
};

(i) Write the names of data members, which are accessible by objects of class type DECORATIVE.
(ii) Write the names of all member functions, which are accessible by the member functions of class FRESH.
(iii) Name the type Inheritance used in the above class?
(iv) How many bytes will be required by an object of class type DECORATIVE?

Ans

(i) Data member;
None
(ii)  Member functions:
void Read_values( )
void Display_values( )
void Set_values( )
void Show_values( )
(iii) Hierarchical Inheritance.
(iv) Number of bytes required by an object of class type DECORATIVE ; 50 Bytes

Question 7:
Answer the questions (i) to (iv) based on the following:    All India 2010

class Director 
{
long DID; 
char Name[20]; 
protected:
char Description[40]; 
void A11ocate(); 
public:
Director(); 
void Assign(); 
void Show();
};
class Factory : public Director 
{
int FID;
char Address[20]; 
protected: 
int NOE;
 public:
Factory(); 
void Input(); 
void Output();
};
class ShowRoom : private Factory 
{
int SID; 
char City[20]; 
public:
ShowRoom(); 
void Enter(); 
void Display();
};

(i) Which type of Inheritance out of the folio wing is illustrated in the above C++ code?
(a) Singlelevel Inheritance
(b) Multilevel Inheritance
(c) Multiple Inheritance
(ii) Write the names of data members, which are accessible by objects of class type ShowRoom.
(iii) Write the name of all member functions, which are accessible by objects of class type ShowRoom.
(iv) Write the names of all members, which are accessible from member function of class Factory.
Ans
(i) Multilevel Inheritance.
(ii)  None
(iii) Enter(), Display()
(iv) Data members:  FID, Address, NOE, Description.
Member functions:   Input(), Output(), Assign(), Show(), Allocate().

Question 8:
Answer the questions (i) to (iv) based on the following:    Delhi 2009C

class QUALITY 
{
private:
char Material[30]; 
float thickness; 
protected:
char manufacturer[20]; 
public:
QUALITY(); 
void READ(); 
void WRITE();
};
class QTY : public QUALITY 
{
long order; 
protected: int stock; 
public:
double *P;
QTY();
void RQTY(); 
void SQTY(); 
};
class FABRIC : public QTY
{
private:
int fcode.fcost; 
public:
FABRIC(); 
void RFABRIC(); 
void SFABRICO;
};

(i) Mention the member names that are accessible by an object of QTY class.
(ii) Name the data members, which can be accessed by the objects of FABRIC class.
(iii) Name the members that can be accessed by the function of FABRIC class.
(iv) How many bytes will be occupied by an object of class FABRIC?
Ans

(i) Data member:
P
Member functions:
RQTY( ),SQTY( ),READ( ),WRITE().
(ii) Data member:
P
(iii) Names of members accessible by member
function of class FABRIC
Data members:
fcode, fcost, stock, P, manufacturer.
Member functions:
RFABRIC( ),SFABRIC( ),RQTY(),
SQTY( ),READ(), WRITE().
(iv) 66 Bytes

Question 9:
Answer the questions (i) to (iv) based on the following code:    Delhi 2008

class Dolls
{
char DCode[5]; 
protected: 
float Price: 
void CalPrice(float); 
public:
Dolls();
void DInput();
void DShow();
}:
class SoftDolls : public Dolls 
{
char SDName[20]; 
float Weight;
public:
SoftDolls(); 
void SDInput(); 
void SDShow();
class ElectronicDolls : public Dolls 
{
char EDname[20]; 
char BatteryType[10]; 
int Batteries: 
public:
ElectronicDolls(); 
void EDInput(); 
void EDShowO;
}:

(i) Which type of Inheritance is depicted by the above example?
(ii) How many bytes will be required by an object of the class ElectronicDolls?
(iii) Write name of all the data members accessible from member function of class SoftDolls.
(iv) Write name of all the member functions accessible by an object of the class ElectronicDolls.

Ans

(i) Hierarchical Inheritance.
(ii) 41 Bytes
(iii) Price, SDName, Weight.
(iv) DInput(), DShow(), EDInput(), EDShow().

Question 10:
Answer the questions (i) to (iv) based on the following:    Delhi 2009

class FacetoFace
{
char CenterCode[10]; 
public:
void Input(); 
void Output();
}:
class Online 
{
char website[50]:
public:
void Siteln(); 
void SiteOut();
}:
class Training : public FacetoFace, private Online
{
long Tcode; 
float charge:
int period: 
public:
void Register(); 
void Show();
}:

(i) Which type of Inheritance is shown in above example?
(ii) Write names of all member functions accessible from Show() function of class Training.
(iii) Write names of all members accessible through an object of  class Training.
(iv) Is function Output() accessible in function SiteOut()? Justify your answer.
Ans

(i) Multiple Inheritance.
(ii) Register(), Input(), Output(), Siteln(), SiteOut()
(iii) No data member.
Member functions:   Register(), Show(), Input(), Output()
(iv) Yes, it can be accessed by using the object of FacetoFace class, because it is a public member.

Question 11:
For questions (i) to (iii), use the following partial class definitions:

class A 
{
public:
int x; 
private: 
int y; 
protected:
int z:
........
};
class B : public A
{
protected:
int a; 
private: 
int b;
class C : public B
{
private: 
int q;
...........
};

(i) Which of the following lists of data members are accessible in class C?
(a) x, y, z,  a, b, q    (b) a, b, q
(c) a, q                     (d) x,  z, a, q
(e) x, a, q

(ii) Which of the following lists of data members are accessible in class B?

(a)x, y, z, a,b    (b) x, y, z, a
(c) x, z, a,b        (d) z, a, b
(e) a, b

(iii)  Which of the following is true regarding the use of data member y of class A?
(a) It is accessible in A, B and C.
(b) It is accessible in A and B.
(c) It is accessible only in A.
(d) It is accessible only in C.
(e) It is not accessible to any of the three classes.

Ans

(i) (d) x, z, a, q
(ii) (c) x, z, a, b
(iii) (c) it is accessible only in A.

Question 12:
Answer the questions (i) to (iv) based on the following code:

class Trainer 
{
char TNo[5],TName[20]; 
char Specialisation[10];
int Days: 
protected:
float Remuneration; 
void AssignRem(float); 
public:
Trainer(); 
void TEntry(); 
void TDisplay();
};
class Learner
{
char Regno[10],LName[20],Program[10]; 
protected:
int Attendance,Grade; 
public:
Learner(); 
void LEntry(); 
void LDisplay();
};
class Institute : public Learner, public Trainer
{
char ICode[10],IName[20]; 
public:
Institute(); void IEntry(); 
void IDisplay();
};

(i) Which type of Inheritance is shown in the above example?
(ii) Identify the member function(s) that cannot be called directly from the objects of class Institute from the following
(a) TEntry()
(b) LDisplay()
(c) IEntry()
(iii) Write name of all the data members accessible from member functions of class Institute.
(iv) If class Institute was derived privately from class Learner and privately from class Trainer, then name the member functions that could be accessed through objects of class Institute.
Ans

(i) Multiple Inheritance
(ii) None(since, all of these functions can be called from object of class Institute).
(iii) Remuneration, Attendance, Grade, ICode, IName
(iv) IEntry( ),IDisplay()

Question 13:
Answer the questions (i) to (iii) based on the following code:

class stationary
{
class 
char Type;
char Manufacturer[10]; 
public:
stationary();
void Read_sta_details();
void Disp_sta_details();
};
class office : public stationary 
{
int no_of_types; 
float cost_of_sta; 
public:
void Read_off_details(); 
void Disp_off_details();
};
class printer : private office 
{
int no_of_user; 
char del ivery_details[10]; 
public:
void Read_pri_details(); 
void Disp_pri_detai1s();
};
void main()
{
printer MyPrinter;
}

(i) Mention the member names, which are accessible by MyPrinter declared in main() function.
(ii) What is the size of MyPrinter in bytes?
(iii) Mention the names of functions accessible from the member function Read_pri_details() of class printer.

Ans

(i) Data members:  None
Member functions: Read_pri_details(), Disp_pri_details().
(ii) 29 Bytes
(iii)Member functions: Read_sta_details(),
Disp_sta_details(),
Read_off_details(),
Disp_off_details(),
Disp_pri_details().

Question 14:
Answer the questions (i) to (iv) based on the folio wing code:

class Medicines 
{
char Category[10]; 
char Date_of_manufacture[10]; 
char Company[20]; 
public:
Medicines();
void entermedicinesdetails(); 
void showmedicinesdetai1s();
};
Capsule : public Medicines 
{
char capsule_name[30]; 
char volume_label[20];
public:
float Price;
Capsule();
void entercapsuledetails(); 
void showcapsuledetai1s();
};
class Antibiotics : public Capsule
{
int Dosage_units; 
char Side_effects[20];
int Use_within_days;
public:
Antibiotics();
void enterdetails();
void showdetails();
};

(i) How many bytes will be required by an object of class Medicines and an object of class Antibiotics, respectively?
(ii) Write names of all the member functions accessible from the object of class Antibiotics.
(iii) Write names of all the members accessible from member functions of class Capsule.
(iv) Write names of all the data members, which are accessible from objects of class Antibiotics.

Ans

(i)  class Medicines:  40 Bytes
class Antibiotics: 118 Bytes
(ii) entermedicinesdetails( ),
showmedicinesdetails( ), entercapsuledetails(),
showcapsuledetails( ),
enterdetaj|ls( ), showdetails( )
(iii) Member functions:
entermedicinesdetails( ),
showmedicinesdetails( ), entercapsuledetails( ),
showcapsuledetails( )
Data members:
capsule_name,volume_label, Price
(iv) Price

Question 15:
Answer the questions (i) to (iv) based on the following code:

class cloth 
{
char category[5]; 
char description[25]; 
protected: 
float price; 
public:
void Entercloth(): 
void dispcloth(); 
cloth()
{ }
}:
class design : protected cloth 
{
char Design[20]: 
protected:
float cost_of_cloth; 
public:
int design_code; 
design(){} 
void Enterdesign(); 
void dispdesign();
};
class costing : public cloth 
{
float designfee; , 
float stitching; 
float cal_cp(); 
protected:
float costprice; 
float sellprice; 
public:
void Entercost(); 
void dispcost(); 
costing(){}
};

(i) Write the names of data members, which are accessible from objects belonging to class cloth.
(ii) Write the names of all members, which are accessible from objects belonging to class design.
(iii) Write the names of all the data members, which are accessible from member functions of class costing.
(iv) How many bytes will be required by an object belonging to class design?
Ans

(i) There is no data member, which can directly be accessed from objects belonging to class cloth.
(ii) The members which are accessible from objects belonging to class design:
designeode, Enterdesign(), dispdesign().
(iii) The data members which are accessible from member functions of class costing:
price, designfee, stitching, costprice, sellprice.
(iv) 60 Bytes will be required by an object belonging to class design.

Question 16:
Answer the questions (i) to (iv) based on the following code:

class Base
{
int A1; 
void BF1(); 
protected:
int B1; 
void BF2(); 
public: 
int C1; 
void BF3();
}ob1;
class Middle : private Base
{
int A2; 
protected:
int B2; 
void MF1(); 
public: 
int C2; 
void MF2();
} ob2;
class Derived : protected Middle 
{
void DFIO; int A3; public: int B3; void DF2();
} ob3;

(i) Name the member function accessible by the objects of Derived.
(ii) Name the data members that are accessible in function DF1().
(iii) What would be the size of class Derived objects?
(iv) Name the data members that are accessible in function F1().
Ans

(i) DF2()
(ii) B2, C2, A3, B3
(iii) 16
(iv) Data members that are accessible in function Fl() are none, because the function Fl() is not the member function of any class.

Question 17:
Answer the questions (i) to (iv) based on the following code:

class MNC
{
char Cname[25];
protected:
char Hoffice[25]; 
public:
MNC();
char country[25]; 
void EnterData(); 
void DisplayData();
};
class Branch : public MNC 
{
long NOE; char ctry[25]; 
protected:
void Association(); 
public:
Branch(); 
void Add(); 
void Show();
};
class Outlet : public Branch 
{
char state[25]; 
public:
Outlet(); 
void Enter(); 
void Output();
};

(i) Which class constructor will be called first at the time of declaration of an object of class Outlet?
(ii) How many bytes does an object belonging to class Outlet require?
(iii) Name the member function(s), which can be accessed by an object of class Outlet.
(iv) Name the data member(s), which can be accessed from the object(s) of class Branch.
Ans

(i) First of all constructor of class MNC will be
called, then of Branch and then at last of Outlet.
(ii) 129 bytes
(iii) EnterData(),  DisplayData(),
Add(),            Show(),
Enter(),         Output().
(iv) country

Question 18:
Answer the questions (i) to (iv) based on the following code:

class A
{
void anyval();
protected:
int x,y;
void procval();
public:
void getval();
void putval();
};
class B : protected A
{
int a,b;
protected:
int c, d ;
void getvalB();
public:
void putvalB();
};
class C : private B
{
int p;
protected:
int q;
void getval();
public:
void showval();
};

(i) Name all the member functions, which are accessible by the objects of class C.
(ii) Name all the protected members of class B.
(iii) Name the base class and derived class of B.
(iv) Name the data member(s), which can be accessed by the member function of class C.
Ans

(i) showval()
(ii) x, y, c, d, procval(), getvalB(), getval( ),putval()
(iii) Base class : A
Derived class : C
(iv) p, q, c, d, x, y

Question 19:
Consider the following C++ declarations and answer the questions given below:

class Alpha 
{
int x, y; 
protected:
void PutValA(); 
public:
void GetValA();
};
class Beta : private Alpha 
{
int m,n; 
protected:
void GetValB(); 
public:
void PutValB();
};
class Gamma : protected Beta 
{
int a; 
public:
void GetData();
void ShowData();
};

(i) Write the names of member functions, which are accessible from the objects of class Gamma.
(ii) Write names of data members, which are accessible from the member functions of class Beta.
(iii) Name the base class and derived class of class Beta.
(iv) Name the private member functions of class Gamma.

Ans

(i) GetData(),
ShowData().
(ii) m and n.
(iii) The base class is Alpha and the derived class is Gamma.
(iv) There is no private member function in class Gamma.

Question 20:
Consider the following declarations and answer the questions given below:

class Vehicle
{
int wheels;
protected:
int passenger;
public:
void InputData(int.int);
void OutputData();
};
class Heavy_Vehicle : protected Vehicle
{
int diesel_petrol;
protected:
int load;
public:
void ReadData(int,int);
void WriteData();
};
class Bus : private Heavy_Vehicle
{
char make[20];
public:
void FetchData(char);
void DisplayData();
};

(i) Name the base class and derived class of the class Heavy_Vehicle.
(ii) Name the data member(s) that can be accessed from function DisplayData().
(iii) Name the member functions that can be accessed by an object of Heavy_Vehicle class.
(iv) Is the member function OutputData() accessible to the objects of Heavy_Vehicie class?

Ans

(i) Base class : Vehicle Derived class : Bus
(ii) make, load, passenger
(iii) ReadData(), WriteData()
(iv) No, the member function OutputData( ) is not accessible to the objects of Heavy_Vehicle class.

Question 21:
Consider the following C++ code: HOTS

class Data
{
int num; 
public:
Data(int n)
{
num=n;
}
void show()
{
cout<<"Data Number: "<<num<<endl;
}
};
class Database : public Data 
{
char name[12]; 
int d; 
public:
________ //Fill in the blank
void dshow() 
{
cout<<"Database Name: "<<name; 
cout<<"\nDatabase Value: ”<<d;
}
};
void main()
{
Database d("SQL"10); 
d.show(); 
d.dshow(); 
getch();
}

(i) Name the type of Inheritance illustrated in the above C++ code.
(ii) Fill in the blank to define a constructor for the derived class assigning values of the data passed from main() and to assign a data 15 to base class constructor data number.
(iii) Write the output of the above C++ code.
Ans

(i) Single Inheritance.
(ii)

Database(char na [12], int value):
Data (15)
{
strcpy(namfe.na); 
d=value;
}

(iii) Output
Data Number: 15
Database Name: SQL
Database Value: 10

Question 22:
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 1ocation[20];
 int workers;
 protected:
 double salary;
 void Computer();
 public:
 FACTORY();
 void Enter();
 void Show();
 };
 class SHOP : private COMPANY
 {
 char 1ocation[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 SHOP.
(iii) Write the name of all the member functions, which are accessible from objects belonging to class FACTORY.
(iv) Write the names of all the members, which are accessible from objects of class SHOP. All India 2012

Ans

(i) Hierarchical Inheritance
(ii) Data members; location, area, sale.
(iii) Member functions:
Enter(), Show(), Register(), Show().
(iv) Data member:
None
Member functions:
Input(), Output()

Question 23:
Identify the error(s) in the following program code:

 Line 1   Class   A
 Line 2   {
 Line 3    private: int x1;
 Line4    public: int x2;
 Line5    protected: int x3;
 Line 6    };
 Line 7    class B : public A
 Line 8    {
 Line 9    public:
 Line 10    void fun()
 Line 11    {
 Line 12    int y1,  y2, y3;
 Line 13    y1=x1;
 Line 14    y2=x2;
 Line 15    y3=x3;
 Line 16    }
 Line 17    };
 Line 18    class C : A
 Line 19    {
 Line 20    public:
 Line 21    void f()
 Line 22    {
 Line 23    int z1, z2, z3;
 Line 24    z1=x1;
 Line 25    z2=x2;
 Line 26    z3=x3;
 Line 27    }
 Line 28    };
 Line 29    void main()
 Line 30    {
 Line 31    int p, q, r, i, j ;
 Line 32    B Obj1;
 Line 33    C Obj 2;
 Line 34    p = Obj1.x1
 Line 35    q = Obj1.x2
 Line 36    r = Obj1,x3
 Line 37    i = Obj 2.x1
 Line 38    j = Obj 2.x2
 Line 39    k = 0bj2.x3
 Line 40    k = Obj1.z1
 Line 41    0bj2.fun();
 Line 42    }

Answer:

Line No 13, 24 → yl = xl and zl =xl, as xl is a private member so it can not be accessed by the derived class and the main() function.
•    Line No 34→ p=Objl.xl; As xl is not accessible by class B.
•    Line No 36→ r=Objl.x3; As x3 is not accessible by class C.
•    Line No 37→ i = Obj2.xl; As xl is not accessible by class C.
•    Line No 38 → j = Obj2.x2; As x2 is not accessible by class C.
•    Line No 39 → k = Obj2.x3; As x3 is not accessible by class C.
•    Line No 40 → k=Obj 1 .z 1; As z 1 is not a member of class B.
•    Line No 41 → Obj2.fun(); fun() is not member of class C and there is no relationship between class B and class C.

Computer ScienceChapterwise Question Bank for Computer ScienceNCERT Solutions

Primary Sidebar

NCERT Exemplar problems With Solutions CBSE Previous Year Questions with Solutoins CBSE Sample Papers

Recent Posts

  • Up From Slavery Summary CBSE Class 11 English Novel
  • NCERT Class 10 Science Lab Manual – pH of Samples
  • NCERT Solutions for Class 11 Hindi Core – काव्य भाग – मेरे तो गिरधर गोपाल दूसरो न कोई, पग घुँघरू बाधि मीरां नाची
  • Glimpses of India Extra Questions and Answers Class 10 English First Flight
  • ML Aggarwal Class 7 Solutions for ICSE Maths Chapter 16 Perimeter and Area Ex 16.1
  • NCERT Solutions for Class 12 Chemistry Chapter 12 Aldehydes, Ketones and Carboxylic Acids
  • Magnetic Effects of Electric Current Class 10 Important Questions with Answers Science Chapter 13
  • Paragraph Writing for Class 8 CBSE Format, Topics Exercises, and Examples
  • Question Tags Exercises for Class 8 CBSE With Answers – English Grammar
  • NCERT Solutions for Class 12 Hindi Core – पूरक पाठ्यपुस्तक-सिल्वर वैडिंग
  • Light Reflection and Refraction Class 10 Important Questions with Answers Science Chapter 10
  • ML Aggarwal Class 8 Solutions for ICSE Maths Chapter 18 Mensuration Ex 18.3
  • NCERT Solutions for Class 12 Chemistry Chapter 11 Alcohols, Phenols and Ehers
  • NCERT Solutions for Class 11 Hindi Core – गद्य भाग – जामुन का पेड़
  • MCQ Questions for Class 8 Science Chapter 16 Light with Answers

Footer

Maths NCERT Solutions

NCERT Solutions for Class 12 Maths
NCERT Solutions for Class 11 Maths
NCERT Solutions for Class 10 Maths
NCERT Solutions for Class 9 Maths
NCERT Solutions for Class 8 Maths
NCERT Solutions for Class 7 Maths
NCERT Solutions for Class 6 Maths

SCIENCE NCERT SOLUTIONS

NCERT Solutions for Class 12 Physics
NCERT Solutions for Class 12 Chemistry
NCERT Solutions for Class 11 Physics
NCERT Solutions for Class 11 Chemistry
NCERT Solutions for Class 10 Science
NCERT Solutions for Class 9 Science
NCERT Solutions for Class 7 Science
MCQ Questions NCERT Solutions
CBSE Sample Papers
NCERT Exemplar Solutions LCM and GCF Calculator
TS Grewal Accountancy Class 12 Solutions
TS Grewal Accountancy Class 11 Solutions