Sunteți pe pagina 1din 4

KENDRIYA VIDYALAYA,SAC AHMEDABAD

Class XII
Subject Computer Science
Summer Vacation Holiday

Note: (i)All questions are compulsory. (ii) Programming Language: C++ (iii) Total Pages: 06
Q1. What are the first and last values of i output by this loop?

n = 10;
i = 0;
while (++i < n)
{

cout<<i<<endl;

Q2. Answer the questions (i) to (iv) based on the following code:
A.

4 X 4 =16

class country
{
int h;
protected:
int s;
public:
void input(int);
void output();

};
class state : private country
{
int t;
protected:
int u;
public:
void indata(int,int);
void outdata();

(i)

};
class city : public state
{
int m;
public:
void display(void);
};
Name the base class and derived class of the class state.

(ii)

Name the data members that can be accessed from function display();

(iii)

Name the member function(s), which can be accessed from the objects of class city.

(iv)

Is the member function output() accessible by the objects of the class state?

Q.3)

(i)

class livingbeing
{
char specification[20];
int averageage;
public:
void read();
void show();
};
class ape : private livingbeing
{
int no_of_organs, no_of_bones;
protected:
int iq_level;
public:
void readape();
void showape();
};
class human : public ape
{
char race[20];
char habitation[30];
public:
void readhuman();
void showhuman();
};
Name the members which can be accessed from the member functions of class human.

(ii)

Name the members, which can be accessed by an object of class human.

(iii)

What will be the size of an object (in bytes) of class human.

(iv)

Name the class(es) that can access read() declared in livingbeing class.

Q.4)
class A
{
void any();
protected:
int a,b;
void proc();
public:
A( );
void get( );
void put( );
};
class B:protected A
{
int c,d;
protected:
int e,f;
void get2( );
public:
B( );
void put2( );
};
class C: private B
{
int p;
protected:
int q;
void get3( );
public:
void show3( );
};
(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 all the data members which are accessible from member functions of class C
(iv) How many bytes does as object belonging to class C require?
Q.5)

(i)
(ii)
(iii)
(iv)

class university
{
int noc;
protected:
char uname[25];
public:
university();
char state[25];
void enterdata();
void displaydata();
};
class college : public university
{
int nod;
char cname[25];
protected:
void affiliation();
public:
college();
void enroll(int,int);
void show();
};
class department : public college
{
char dname[25];
int nof;
public:
department();
void display();
void input();
}
Which classs constructor will be called first at the time of declaration of an object of class department.
How many bytes does an object belonging to class department require?
Name the member function(s), which are accessed from the object(s) of class department.
Name the data member(s), which are accessible from the object(s) of class college.
Q.6 Answer the questions (i) to (iv) based on the following:
class Regular
{
char Collegecode[10];
public:

void InRegular();
void OutRegular();
};
class Distance
{protected:
char StudyCentreCode[5];
public:
void InDistance();
void OutDistance();
};
class Course : public Regular, Distance
{
char Code[5];
float fees;
int duration;
public:
void InCourse();
void OutCourse();
};

(i)
(ii)
(iii)
(iv)

Which type of inheritance is shown in the above example?


Write names of all the member functions accessible from OutCourse function of class Course.
Write name of all the members accessible through an object of the class Course.
Is the function InRegular() accessible inside the function InDistance()? Justify your answer.

Q.7 Answer the questions (i) to (iv) based on the following:


class cloth
{
char category [5];
char description [25];
protected :
float price;
public :
void entercloth ( );
void displaycloth ( );
};
class design : protected cloth
{
char design [21];
protected :
float cost;
public:
int design;
design ( ) { }
void enterdesign ( );
void dispdesign ( );
};
class costing : public cloth
{
float desingfee;
float stiching;
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?
Q.8Rewrite the following after making corrections in the following code, if any. Also underline the corrections made.
class new
{
int a=5;
float t;
void new (int x)
{t = x; }
~ new(int l) { }

};
void main()
{
new n,m;
}
Q.9 What is Function Overloading? Give an example in C++ to illustrate the same.
Q.10Answer the questions (i) and (ii) after going through the following program:
#include<iostream.h>
#include<string.h>
class AirIndia
{
char flno;
int Nop;
public:
AirIndia()
//function1
{
strcpy(flno, );
Nop=0;
}
AirIndia( chat *str,int n)
//function2
{
strcpy(flno,str);
Nop=n;
}
void input
//function3
{
cin>>flno;
cin>>Nop;
}
~AirIndia()
//function4
{
cout<<counter closed<<endl;
}
};
Q.11In Object Oriented Programming, which concept is illustrated by Function1 and Function2 together? Write
the statement to call these functions.
What is the scope of two data members of the class AirIndia? What does the scope of data members depend
upon?
Define a class BOOK with the following specification :
(4)
Private members of the class BOOK are
book_no
integer type
book_title
20 characters
price
float (price per copy )
total_cost ( )
A function to calculate the total cost for N number of copies, where N is passed to the function as argument.
Public members of the class BOOK are
input ( )
Function to read book_no, book_title, price
purchase ( )
Function to ask the user to input the number of copies to be purchased. It invokes total_cost( ) and prints the total cost to be
paid by the user.
Q.12 Define a class Student in C++ with the description given below :
4
private members
rno
integer
name
array of 40 characters
address
array of 40 characters
marks
array of 5 integers
percentage float variable
calper()
a function which will calculate & return the percentage of a student.
public members
init()
function to ask and store the values of rno, name, address and marks in 5 subjects.
display()
function to which will invoke calper () and display the details of the item in the following
format :
MARK SHEET
Roll No : <Roll no of student>
Name
:
<Student Name >
Address : <ADDRESS >
Marks : <subject1 marks><subject 2 marks ><.subject 5 marks>
Percentage :
<percentage of the student>
Also create main() function which will invoke all the public member functions.

S-ar putea să vă placă și