Nothing Special   »   [go: up one dir, main page]

Testclassesconsinh

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

LET’S CODE TOGETHER

Class-XII – Computer Sciences


TEST-2
Max-Marks:30 Total time:1:00hrs

1.

(a) What do you understand by Data Encapsulation and Data Hiding?

(b) Answer the questions (i) and (ii) after going through the following class:
class Seminar
{
int Time;
public:
Seminar() //Function 1
{
Time=30;cout<<”Seminar starts now”<<end1;
}
void Lecture() //Function 2
{
cout<<”Lectures in the seminar on”<<end1;
}
Seminar(int Duration) //Function 3
{
Time=Duration;cout<<”Seminar starts now”<<end1;
}
~Seminar() //Function 4
{
cout<<”Vote of thanks”<<end1;
}
};

i) In Object Oriented Programming, what is Function 4 referred as and when does it get
invoked/called?

ii) In Object Oriented Programming, which concept is illustrated by Function 1 and


Function 3 together? Write an example illustrating the calls for these functions.

(c) Define a class TEST in C++ with following description: 4


Private Members
a. TestCode of type integer
b. Description of type string
c. NoCandidate of type integer
d. CenterReqd (number of centers required) of type integer
e. A member function CALCNTR() to calculate and return the number of
centers as (NoCandidates/100+1)
Public Members
A function SCHEDULE() to allow user to enter values for TestCode,
Description, NoCandidate & call function CALCNTR() to calculate the number
of Centres
A function DISPTEST() to allow user to view the content of all thedata members
(d) Answer the questions (i) to (iv) based on the following:
class PUBLISHER
{
char Pub[12]; double
Turnover;
protected:
void Register(); public:
PUBLISHER(); void
Enter(); void Display();
};
class BRANCH
{
char CITY[20];
protected:
float Employees;
public:
BRANCH(); void
Haveit(); void
Giveit();
};

class AUTHOR:private BRANCH,public PUBLISHER


{
int Acode; char
Aname[20]; float
Amount;
public:
AUTHOR(); void
Start(); void
Show();
};

(i) Write the names of data members, which are accessible from objects belonging to class
AUTHOR.

(ii) Write the names of all the member functions which are accessible from objects belonging to
class BRANCH.
(iii) Write the names of all the members which are accessible from member functions of class
AUTHOR.
(iv) How many bytes will be required by an object belonging to class AUTHOR?

2.
(a) What is a copy constructor? What do you understand by constructor overloading?
(b) Define a class student with the following specification
Private members of class student
admno integer
sname 20 character
eng. math, science float
total float
ctotal() a function to calculate eng + math + science with
float return type.

Public member function of class student


Takedata() Function to accept values for admno, sname, eng, math,
science and invoke ctotal() to calculate total.
Showdata() Function to display all the data members on the screen.
(c) Consider the following declaration and answer the questions given below :

class PPP
{
int H:
protected :
int S;
public :
void INPUT (int);
void OUT();
};
class QQQ : private PPP
{
int T;
protected :
int U;
public :
void INDATA(int, int);
void OUTDATA();
};
class RRR : public QQQ
{
int M;
public
:
void DISP( void );
};
(i)Name the base class and derived class of the class QQQ.
(ii) Name the data member(s) that can be accessed from function DISP().
(iii) Name the member function(s), which can be accessed from the objects of class
RRR. (iv)Is the member function OUT() accessible by the object of the c.ass QQQ?
3. (a) Given the following C++ code, answer the questions (i) & (ii).
class TestMeOut
{
public:
~TestMeOut() //Function 1
{cout<<“Leaving the examination hall”<<endl;}

TestMeOut() //Function 2
{cout<<“Appearing for examination”<<endl;}

void MyWork() //Function 3


{cout<<“Attempting Questions//<<endl;}
};

(i) In Object Oriented Programming, what is Function 1 referred as and when


does it get invoked / called ?
(ii) In Object Oriented Programming, what is Function 2 referred as and when
does it get invoked / called ?
(b) Declare a class myfolder with the following specifications :
private members of the class
Filenames — an array of strings of size [10] [25]
(to represent all the names of files inside myfolder)
Availspace — long
(to represent total number of bytes available in myfolder)
Usedspace — Long
(to represent total number of bytes used in myfolder)
public members of the class
Newfileentry( ) - A function to accept values of Filenames, Availspace and
Usedspace from user
Retavailspace( ) - a function that returns the value of total Kilobytes
available
(1 Kilobyte = 1024 bytes)
Showfiles( ) - a function that displays the names of all the files in myfolder
(c) Given the following class definitions answer the questions that follow :
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();
};

(i) 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 ape.
(iii) Name the members, which can be accessed by an object of class human.
(iv) What will be the size of an object (in bytes) of class human ?

You might also like