kendriya vidyalaya ballygunge summer • a data member rno (registration number) of type long ......

17
KENDRIYA VIDYALAYA BALLYGUNGE SUMMER VACATION HOLIDAY HOMEWORK COMPUTER SCIENCE IMPORTANT QUESTIONS (1 OR 2 TIMES) Chapter Introduction to OOP using C++ 1. 20 05 Define the term Data Hiding in the context of Object Oriented Programming. Give a Suitable example using a C++ code to illustrate the same. 2 Define a class TravelPlan in C++ with the following descriptions : Private Members: PlanCode of type long Place of type character array (string) Number_of_travellers of type integer Number_of_buses of type integer Public Members: A constructor to assign initial values of Plan Code as 1001, Place as “Agra”, Number_of_travellers as 5, Number_of_buses as 1 A function NewPlan( ) which allows user to enter PlanCode, Place and Number_of_travellers. Also, assign the value of Number_of_buses as per the following conditions : Number_of_travellersNumber_of_buses Less than 20 Equal to or more than 20 and less than 40 Equal to 40 or more than 40 3 A function ShowPlan( ) to display the content of all the data members on screen. 4 2. 20 06 Define Multilevel and Multiple inheritance in context of Object Oriented Programming. Give suitable example to illustrate the same. 2 Define a class named ADMISSION in C++ with the following descriptions: Private members: AD_NO integer (Ranges 10 - 2000) NAME Array of characters (String) CLASS Character FEES Float Public Members: Function Read_Data ( ) to read an object of ADMISSION type Function Display() to display the details of an object Function Draw-Nos ( ) to choose 2 students randomly. And display the details. Use random function to generate admission nos. to match with AD_NO. ( 4 ) 20 07 What do you understand.by Data Encapsulation and Data·Hiding?Also,giveanexampleinC++toillustrateboth. 2 Define a class STOCK in C++ with following description : Private Members !Code of type integer (Item Code) 4

Upload: dangcong

Post on 04-Feb-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: KENDRIYA VIDYALAYA BALLYGUNGE SUMMER • A data member RNo (Registration Number) of type long ... class Interview { int month; public: Interview (int y) {month=y ;} //Constructor 1

KENDRIYA VIDYALAYA BALLYGUNGE

SUMMER VACATION HOLIDAY HOMEWORK

COMPUTER SCIENCE

IMPORTANT QUESTIONS (1 OR 2 TIMES)

Chapter – Introduction to OOP using C++

1. 2005

Define the term Data Hiding in the context of Object Oriented Programming. Give a

Suitable example using a C++ code to illustrate the same.

2

Define a class TravelPlan in C++ with the following descriptions :

Private Members:

PlanCode of type long

Place of type character array (string)

Number_of_travellers of type integer

Number_of_buses of type integer

Public Members:

A constructor to assign initial values of Plan Code as 1001, Place as “Agra”,

Number_of_travellers as 5, Number_of_buses as 1

A function NewPlan( ) which allows user to enter PlanCode, Place and

Number_of_travellers. Also, assign the value of Number_of_buses as per the

following conditions :

Number_of_travellersNumber_of_buses

Less than 20

Equal to or more than 20 and less than 40

Equal to 40 or more than 40 3

A function ShowPlan( ) to display the content of all the data members on screen.

4

2. 2006

Define Multilevel and Multiple inheritance in context of Object Oriented Programming. Give suitable example to illustrate the same.

2

Define a class named ADMISSION in C++ with the following descriptions: Private members: AD_NO integer (Ranges 10 - 2000) NAME Array of characters (String) CLASS Character FEES Float Public Members: Function Read_Data ( ) to read an object of ADMISSION type Function Display() to display the details of an object Function Draw-Nos ( ) to choose 2 students randomly. And display the details. Use random function to generate admission nos. to match with AD_NO.

(4)

2007

What do you understand.by Data Encapsulation and

Data·Hiding?Also,giveanexampleinC++toillustrateboth.

2

Define a class STOCK in C++ with following description : Private Members • !Code of type integer (Item Code)

4

Page 2: KENDRIYA VIDYALAYA BALLYGUNGE SUMMER • A data member RNo (Registration Number) of type long ... class Interview { int month; public: Interview (int y) {month=y ;} //Constructor 1

• Item of type string (Item Name) • . Price of type float (Price of each item) • Qty of type. integer (Quantity in stock) • Discount of type float (Discount percentage on the itedJ.) • A member function FindDisc() to calculate discount s per the following rule : If Qty<=50 Discount is 0 If 50<Qty<=l00 . Discount is 5 If Qty> lOO Discount is 10 Public Members • A function Buy() to allow user to enter values for Code, Item, Price,. Qty and call function FindDisc() to calcula& the Discount.

• A • function ShowAll() to allow user to view the content of all the data

members. 2008

Differentiatebetweenmembers,whicharepresentwithintheprivatevisibility

modewiththosewhicharepresentwithinthepublicvisibilitymodes.

2

Define a class Candidate in C++ with following description :

Private Members

• A data member RNo (Registration Number) of type long

• A data member Name of type string

• A data member Score of type float

• A data member Remarks of type string

• A member function AssignRem( ) to assign Remarks as per the Score

obtained by a candidate. Score range and the respective Remarks are shown as

follows :

Score Remarks

>=50 Selected

lessthan50Notselected

PublicMembers

AfunctionENTER()toallowusertoentervaluesforRNo,Name,S

core&callfunctionAssignRem()toassigntheremarks.

AfunctionDISPLAY()toallowusertoviewthecontentofallthedatamembers.

4

2009

What is copy constructor? Give an example in C++ to illustrate copy constructor.

2

Define a class Applicant in C++ with following description : Private Members • A data member ANo (Admission Number) of type long

4

Page 3: KENDRIYA VIDYALAYA BALLYGUNGE SUMMER • A data member RNo (Registration Number) of type long ... class Interview { int month; public: Interview (int y) {month=y ;} //Constructor 1

• A data member Name of type string • A data member Agg (Aggregate Marks) of type 'float • A data member Grade of type char • A member function GradeMe() to find the Grade as per the Aggregate Marks obtained by a student. Equivalent Aggregate Marks range and the respective Grades are shown as follows : Aggregate Marks Grade >=80 A less than 80 and >=65 B less than 65 and >=50 c less than 50 D :, Public Members • A function ENTER() to allow user to enter values for ANo, Name, Agg & call function GradeMe() to find the Grade. • A function RESULT() to allow user to view the content of all the data members.

2010

What do you understand . by Data Encapsulation and Data • Hiding ? Also, give an example in C++ to illustrate both.

Define a class STOCK in C++ with following description : Private Members • !Code of type integer (Item Code) • Item of type string (Item Name) • . Price of type float (Price of each item) • Qty of type. integer (Quantity in stock) • Discount of type float (Discount percentage on the itedJ.) • A member function FindDisc() to calculate discount s per the following rule : If Qty<=50 Discount is 0 If 50<Qty<=l00 . Discount is 5 If Qty> lOO Discount is 10 Public Members • A function Buy() to allow user to enter values for Code, Item, Price,. Qty and call function FindDisc() to calcula& the Discount. • A • function ShowAll() to allow user to view the contentof all the data members.

2011

Differentiate between Constructor and Destructor function with respecttoObjectOrientedProgramming.

2

(c) Define a class Applicant in C++ with following description : Private Members • A data member ANo (Admission Number) of type long • A data member Name of type string • A data member Agg (Aggregate Marks) of type 'float • A data member Grade of type char • A member function GradeMe() to find the Grade as per the Aggregate Marks obtained by a student. Equivalent Aggregate Marks range and the respective Grades are shown as follows :

4

Page 4: KENDRIYA VIDYALAYA BALLYGUNGE SUMMER • A data member RNo (Registration Number) of type long ... class Interview { int month; public: Interview (int y) {month=y ;} //Constructor 1

Aggregate Marks Grade >=80 A less than 80 and >=65 B less than 65 and >=50 c less than 50 D :, Public Members • A function ENTER() to allow user to enter values for ANo, Name, Agg & call function GradeMe() to find the Grade. • A function RESULT() to allow user to view the content of all the data members.

2012

What is the difference between the members in private visibility mode and the members in protected visibility mode inside a class? Also, give a suitable C++ code to illustrate both.

2

Define a class RESTRA in C++ with following description: Private Members

FoodCode of type int

Food of type String

FType of type string

Sticker of type string

A member function GetSticker() to assign the following values for Sticker as per the given FType:

FType Sticker

Vegetarian GREEN

Contains Egg YELLOW

Non-Vegetarian RED

Public Members

A function GetFood() to allow user to enter values for FoodCode,Food,FType and call function GetSticker() to assign Sticker.

A function ShowFood() to allow user to view the content of all data members.

4

2013

Write any two differences between Constructor and Destructor. Write the function headers for constructor and destructor of a class Member.

2

Define a class Tourist in C++ with the following specification: Data Members

carno – to store Bus No

Origin – to store Place name

Destination – to store Place name

Type – to store Car Type such as ‘E’ for Economy

Distance – to store the Distance in Kilometers

Charge – to store the car fare Member Functions

A contructor function to initialize Type as ‘E’ and Freight as 250

A function CalcCharge() to calculate Fare as per the following citeria: Type Charge ‘E’ 16 * Distance ‘A’ 22 * Distance ‘L’ 30 * Distance

A function Enter() to alow user to enter values for carno,origin,destination,type and distance. Also this function should call CalcCharge() to calculate Fare.

A function Show () to display the content of all the data members on screen.

4

2014

Write anytwodifferences betweenConstructor andDestructor.Write

functionheadersforconstructoranddestructorofaclassMember.

2

(c) Define a class Tourist in C++ with the following specification :

Data Members

• Camo - to store Bus No

4

Page 5: KENDRIYA VIDYALAYA BALLYGUNGE SUMMER • A data member RNo (Registration Number) of type long ... class Interview { int month; public: Interview (int y) {month=y ;} //Constructor 1

• Origin - to store Place name

• Destination - to store Place name

• Type - to store Car Type such as 'E' for Economy

• Distance - to store the Distance in Kilometers

• Charge - to store the Car Fare Member Functions

• A constructor function to initialize Type as 'E' and Freight as 250

• A function CalcCharge() to calculate Fare as per the following criteria :

Type Charge

' E ' 16*Distance

'A ' 22*Distance

' L ' 30*Distance

• A function Enter() to allow user to enter values for Carno, Origin, Destination,

Type and Distance. Also, this function should call CalcCharge() to calculate Fare.

• A function Show() to display the content of all the data members on screen.

Chapter - Constructor & Destructor

2005

Answer the questions (i) and (ii) after going through the following class: class Test

{

char Paper[20];

int Marks;

public:

Test () // Function 1

{

strcpy (Paper, “Computer”)

Marks = 0;

}

Test (char P [] ) // Function 2

{

strcpy(Paper,P);

Marks = 0;

}

Test (int M) // Function 3

{

strcpy(Paper,”Computer”);

Marks = M;

}

Test (char P[], int M) // Function 4

{

strcpy (Paper, P);

Marks = M;

}

};

(i) Which feature of Object Oriented Programming is demonstrated using

Function 1, Function 2, Function 3 and Function 4 in the above class Test?

(ii) Write statements in C++ that would execute Function 2 and Function 4 of

class Test.

2

Page 6: KENDRIYA VIDYALAYA BALLYGUNGE SUMMER • A data member RNo (Registration Number) of type long ... class Interview { int month; public: Interview (int y) {month=y ;} //Constructor 1

' '

2006

Answer the questions (i) and (ii) after going through the following class: class Interview { int month; public: Interview (int y) {month=y ;} //Constructor 1 Interview (Interview&t); //Constructor 2 }; i. Create an object, such that it invokes Constructor 1. ii. Write complete definition for Constructor 2.

2

2007

Answerthequestions(i)and(ii)aftergoingthroughthefollowing

class: classExam

intRno,MaxMarks,MinMarks,M

arks;public:

Exam() I/Module1 Rno=l01;MaxMarks=lOO;MinMarks=40;Marks

=75;Exam(intPrno,intPmarks)

I/Module

2

Rno=Prno;MaxMarks=lOO;MinMarks=40;Marks=Pmarks;

-Exam() I/Module3 cout<<

11

Exam Over11

<<endl;

void Show() I/Module4

cout<<Rno<<":"<<MaxMarks<<":"<<MinMarks<<endl;cou

t<<"[MarksGot]"<<Marks<<endl;

};

(i) As per ObjectOriented Programming, which

concept isillustrated byModule 1andModule 2together ?

(ii) What is Module 3referred as ? When do you think,

Module3willbeinvoked/called ?

2

2008

Write the output of the following C++ code. Also, write the name of feature of Object Oriented Programming used in the following program jointly illustrated by the functions [I] to [IV]. # include <iostream.h> void Print ( ) // Function [I] {

for(intK=l·K<=60 ·K++)cout<<"-"· ' ,

cout<<endl;

2

Page 7: KENDRIYA VIDYALAYA BALLYGUNGE SUMMER • A data member RNo (Registration Number) of type long ... class Interview { int month; public: Interview (int y) {month=y ;} //Constructor 1

}

voidPrint(intN) 11Function[II]

{

for(intK=l·,K<=N·,L++)cout<<"*"'

·cout<<endl;

}

voidPrint(charT,intN) 11Function[IV]

{

for(intK=l;K<=N;K++)cout<<T;cout

<<endl;

}

voidmain ()

{

intU=9,V=4,W=3;

charC='("a.)',·

Print(C,V);

Print(U,W);

} 2009

Write the output of the following C++ code. Also, write the name of feature of Object Oriented programming used in the following program jointly illustrated by the functions (i) to (iv) : #include<iostream.h> void Line() // Function 1 { for(int L=1; L<= 80; L++) cout<<”-“; cout<<endl; } void Line(int N) // Function 2 { for(int L=1; L<=N; L++) cout<<”*”; cout<<endl; } void Line(char C,A,int N) // Function 3 { for(int L=1; L<=N; L++) cout<<C; cout<<endl; } void Line(intM,int N) // Function 4 { for(int L=1; L<=N; L++) cout<<M*L; cout<<endl; } void main() { int A=9,B=4,C=3; char K=’#’;

2

Page 8: KENDRIYA VIDYALAYA BALLYGUNGE SUMMER • A data member RNo (Registration Number) of type long ... class Interview { int month; public: Interview (int y) {month=y ;} //Constructor 1

Line(K,B); Line(A,C); }

2010

Answer the questions (i) and (ii) after going through the following class : class Exam int Rno,MaxMarks,MinMarks,Marks; public: Exam () I /Module 1 Rno=l01;MaxMarks=l O O;MinMarks=40;Marks=75; Exam (int Prno,int Pmarks) I /Module 2 Rno=Prno;MaxMarks=lO O;MinMarks=40;Marks=Pmarks; -Exam () I /Module 3 cout<< 11 Exam Over 11 <<endl; void Show () I /Module 4 cout<<Rno<<" :"<<MaxMarks<<" :"<<MinMarks<<endl; cout<<" [Marks Got]" <<Marks<<endl; } ;

i) As per ObjectOriented Programming, which

concept isillustrated byModule 1andModule 2together ?

ii) What is Module 3referred as ? When do you think,

Module3willbeinvoked/called ?

2

2011

Write the output of the following C++ code. Also, write the name of feature of Object Oriented Programming used in the following ' program jointly illustrated by the functions [I] to [IV] : *include < iost ream .h> void Line ( ) / / Funct ion [ I ] { f or ( int L= l ; L<=8 0 ; L++ ) cout<<"-"; cout<<endl ; 1', void Line ( int N ) / / Funct ion [ II ] { f or ( int L= l ; L<=N ;L+ + ) cout<<"*"; cout<<endl ; void Line ( cha r C , int N ) / / Funct ion [ I I I ] { f or ( int L= l ;L<=N ;L++) cout<<C ; cout<<endl ; void Line ( int M , int N ) / / Funct ion [IV] { f or ( int L= l ; L<=N ;L++ ) cout<<M*L ; cout<<endl ; void ma in ( ) { int A= 9 , B= 4 , C=3; char K='#'; Line ( K , B) ; Line ( A , C ) ;

Page 9: KENDRIYA VIDYALAYA BALLYGUNGE SUMMER • A data member RNo (Registration Number) of type long ... class Interview { int month; public: Interview (int y) {month=y ;} //Constructor 1

}

2012

Answer the questions(i) and (ii) after going through the following class : class Travel { intPlaceCode; char Place[20]; float Charges; public: Travel() // Function 1 { PlaceCode =1; strcpy(Place,”DELHI”); Charges=1000; } Travel(float C) // Function 2 { Cout<<PlaceCode<<”:”<<Place<<”:”<<Charges<<endl; } ~Travel() // Function 3 { Cout<<”Travel Plan Cancelled”<<endl; } Travel(intPC,char P[],float C) // Function 4 { PlaceCode = PC; strcpy(Place,P); Charges = C; } };

i) In Object Oriented Programming, what are Function 1 and Function 4 combined together referred as ?

ii) In Object Oriented Programming, which concept is illustrate by Function 3? When is this function called/invoked?

2

2013

Answer the question (i) and (ii) after going through the following class : Class Motor { Int MotorNo,Track; Public: Motor(); // Function 1 Motor (int MN); // Function 2 Moto (Motor & M); // Function 3 Void Allocate(); // Function 4 Void Move(); // Function 5 }; Void main() { Motor M; : : }

(i) Out of the following, which of the option is correct foe calling function 2? Option 1 – Moto N(M); Option 2 – Motor P(10);

(ii) Name the feature of Object Oriented Programming, which is illustrated by Function1,Function 2 and Function 3 combined together.

2014

Answer the questions (i) and (ii) after going through the following class :

class Motor

{

int MotorNo, Track; public:

2

Page 10: KENDRIYA VIDYALAYA BALLYGUNGE SUMMER • A data member RNo (Registration Number) of type long ... class Interview { int month; public: Interview (int y) {month=y ;} //Constructor 1

Motor(); //Function 1

Motor (int MN) ; //Function 2 Motor(Motor &M) ; //Function 3 void Allocate {);

//Function 4 void Move(); //Function 5

} ;

void main ()

{

Motor M;

}

(i) Out of the following, which of the option is correct for calling Function 2 ?

Option 1 - Motor N(M ); Option 2 - Motor P(lO ); (ii) Name the feature of Object Oriented Programming, which is illustrated by Function 1, Function 2 and Function 3 combined together.

Chapter - Inheritance

2005

Answer the questions (i) to (iv) based on the following code: 4 class Medicines

{

char Category[lO];

char Date_of_manufacture[lO];

char Company[20];

public:

Medicines();

void entermedicinedetails();

void showmedicinedetails();

} ;

class Capsules: public Medicines

{

protected:

char capsule_name[30];

char Volume_label[20];

public:

float Price;

Capsules();

void entercapsuledetails();

void showcapsuledetails();

};

class Antibiotics: public Capsule

{

intDosage_units;

char Side_effects[20];

intUse_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

Capsules.

(iv) Write names of all the data members, which are accessible from objects of class

Antibiotics.

4

20 Answer the questions (i) to (iii) based on the following code 4

Page 11: KENDRIYA VIDYALAYA BALLYGUNGE SUMMER • A data member RNo (Registration Number) of type long ... class Interview { int month; public: Interview (int y) {month=y ;} //Constructor 1

06 class stationary { char Type; char Manufacturer [10]; public: stationary(); void Read_sta_details( ); void Disp_sta_details( ); }; class office: public stationary { intno_of_types; float cost_of_sta; public: void Read_off_details( ); void Disp_off_details( ); }; class printer: private office { intno_of_users; char delivery_date[10]; public: void Read_pri_details( ); void Disp_pri_details( ); }; 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.

2007

Answerthequestions(i)to(iv)basedonthefollowing

Class·Director { long DID; char Name[20]; protected: charDescription[40]; voidAllocate(); public: Director();voidAss

ign();void Show();

};

classFactory:public Directer {

intFID; I/Factory ID I charAddress[20];

protected:

4

Page 12: KENDRIYA VIDYALAYA BALLYGUNGE SUMMER • A data member RNo (Registration Number) of type long ... class Interview { int month; public: Interview (int y) {month=y ;} //Constructor 1

intNOE; I/No.ofEmployees

public:

Factory();voidInp

ut();

Void Output(); };

classShowRoom:private Factory

{ intSID; I/Showroo:nIDcharCity[20];

public:

ShowRoom();

voidEnter();

voidDisplay();

};

(i)Whichtypeof·inheri tance·,outofthe .followingisillustratedinthe aboveC++ ?

(a) Single level Inheritance

(b) MultiLevelInheritance

(c) Multiple Inheritance (iii) Write the names of members which are accessible by the object of class

showroom. (iv) Write the names of member function which are accessible by the object of class

showroom. (v) Write the names of members which are accessible by the object of class Factory.

2008

Answerthequestions(i)to(iv)based·onthefollowing: class Student { int Rno ; char Name[20] ; float Marks ; protected : void Result ( ) ; public : Student ( ) ; void Register ( ) ; void Display ( ) ; }; class Faculty { long FCode ; char FName [20] ; protected : float Pay ; public : Faculty ( ) ; void Enter ( ) ; void Show ( ) ; }; class Course : public Student, private Faculty { long CCode [IO]; char CourseName [50]; char StartDate [8J, EndDate [8] ; public : Course ( ) ; void Commence ( ) ; void CDetail ( ) ;

4

Page 13: KENDRIYA VIDYALAYA BALLYGUNGE SUMMER • A data member RNo (Registration Number) of type long ... class Interview { int month; public: Interview (int y) {month=y ;} //Constructor 1

}; (i) Which type of inheritance is illustrated in the above C++ code ? (ii) Write the names of all the data members, which is/are accessible from member function Commence of class Course. (iii) Write the names of member functions, which are accessible from objects of class Course. (iv) Write the names of all the members, which are accessible from objects of class Faculty.

2009

Answerthequestions(i)to(iv)based·onthefollowing: Class student { int Rollno; char SName [20]; float Marksl protected: void Result (); public: Student(); void Enroll( );void Display( ); }; Class teacher { long TCode; char TName [20]; protected: float Salary; public: Teacher(); void Enter (); void Show (); }; class Course: public Student , private Teacher { long CCode[lO];char CourseName[ SO]; char StartDate[8],EndDate[8]; public: Course( ); void Commence (); void CDetail (); } ; (i) Write the names of member functions, which are accessible from objects of class Course. (ii) Write the names of all the data members, which is/are accessible from member function Commence of class Course. (iii) Write the names of all .the members, which are accessible from objects of class Teacher. (iv) Which type of Inheritance 1s illustrated in the above C++ code ?

2010

Answerthequestions(i)to(iv)basedonthefollowing

Class·Director { long DID; char Name[20]; protected: charDescription[40]; voidAllocate(); public: Director();voidAss

ign();void Show();

};

Page 14: KENDRIYA VIDYALAYA BALLYGUNGE SUMMER • A data member RNo (Registration Number) of type long ... class Interview { int month; public: Interview (int y) {month=y ;} //Constructor 1

classFactory:public Directer {

intFID; I/Factory ID I charAddress[20];

protected:

intNOE; I/No.ofEmployees

public:

Factory();voidInp

ut();

Void Output(); };

classShowRoom:private Factory

{ intSID; I/Showroo:nIDcharCity[20];

public:

ShowRoom();

voidEnter();

voidDisplay();

};

(i)Whichtypeof·inheri tance·,outofthe .followingisillustratedinthe aboveC++ -' ?·

(d) Single level Inheritance

(e) MultiLevelInheritance

(f) Multiple Inheritance (vi) Write the names of members which are accessible by the object of class

showroom. (vii) Write the names of member function which are accessible by the object of class

showroom. Write the names of members which are accessible by the object of class Factory.

2011

Answerthequestions(i)to(iv)based·onthefollowing: Class Student { Int Rollno; Char SName[20]; Float Marks1; Protected : Void Result(); Public: Student(); Void Enroll(); void display(); }; Class Teacher

Page 15: KENDRIYA VIDYALAYA BALLYGUNGE SUMMER • A data member RNo (Registration Number) of type long ... class Interview { int month; public: Interview (int y) {month=y ;} //Constructor 1

{ Long TCode; Char TName[20]; Protected: Float salary; Public: Teacher(); Void Enter(); Void show(); }; Class Course : public Student , private Teacher { Long CCode[10]; char CourseName[50]; Char StartDate[8],EndDate[8]; Public: Course(); Void Commerce(); Void CDetails(); };

(i) Write the names of member functions, which are accessible from objects of class Course.

(ii)Writethenamesofallthedatamembers,whichis/areaccessiblefromme

mberfunctionCommenceof classCourse.

(iii)Writethenamesofall.themembers,which

areaccessiblefromobjectsofclassTeacher.

(iv)Which type of Inheritance 1s illustrated in the above C++ code ? 2012

Answerthequestions(i)to(iv)basedonthefollowing: class COMPANY char Loca tion [20 ] ; double Budget , Incorne; pr otected : void Accou n ts ( ) ; public : COMPANY ( ) ; void Register ( ) ; void Show ( ) ; } ; cla ss FACTORY :public COMPANY char Location ( 2 0 ) ; int Wor kers; protected : double Salar y; void Computer ( ) ; public : FACTORY () ; void Enter ( ) ; void Show ( ) ; } ; class SHOP : pr ivate COMPANY cha r Loca t ion [ 2 0 ] ; f loat Area ; double Sale ; public : SHOP ( ) ; void Inpu t ( ) ; void Outpu t ( ) ;

Page 16: KENDRIYA VIDYALAYA BALLYGUNGE SUMMER • A data member RNo (Registration Number) of type long ... class Interview { int month; public: Interview (int y) {month=y ;} //Constructor 1

} ;

(i) Name thetype ofinheritanceillustrated m the above C++code.

(ii) Writethenameofdatamembers,which

arcaccessiblefrommemberfunctionsofclassSHOP.

(iii) Write the names of all the member fonctions, which

areaccessiblefromobjectsbelongingtoclassFACTORY.

(iv) Writethe names ofall themembers, which

arcaccessiblefromobjectsofclassSHOP.

2013

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 Stddisplay(); }; 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 members functions , which can be directly accessed

from the objects of class Report. (iv) Write the names of those data members, which can be directly accressed from the

Sentry() function of class Score.

2014

(d) Consider the following C++ code and answer the questions from (i) to (iv) :

class Student { int Class,Rno; char Section; protected :

4

Page 17: KENDRIYA VIDYALAYA BALLYGUNGE SUMMER • A data member RNo (Registration Number) of type long ... class Interview { int month; public: Interview (int y) {month=y ;} //Constructor 1

char SNarne[20]; public : Student(); void Stentry(); void Stdisplay(); } ; class Score: private Student { float Marks[S]; protected: char Grade[S]; public: Score (); void Sentry(); void Sdisplay(); }; class Report: public Score { float Total, Avg; public: char OverallGrade, Remarks [20]; Report(); void REvaluate( ); void RPrint(); } i

(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.