CBSE Sample paper class XII Computer Science 2008 1


Ask a Question

Sample Paper – 2008

Class – XI

Subject – Computer Science

Time allowed : 3 hours Maximum Marks : 70

Instructions : (i) All questions are compulsory

(ii) Programming Language : C++

  1. (2*5)

(a) Write the major differences between Object Oriented Programming and Procedural Programming.

(b) Name the header file, to which following built-in function belong:

(1) Cgets

(2) Floor

(3) isalpha

(4)Gets

(c)What is an inline function? Specify the conditions when you can not create inline function?

(d) What are the advantages offered by inheritance?

(e) What is a parameter? Differentiate between an actual and a formal parameter with an

example?

a.Consider the following declaration:

class TRAIN

{ int trainno;

char dest[20];

float distance;

public:

void get( ); //To read an object from the keyboard

void put( ); //To write an object into a file

void show( ); //To display the file contents on the monitor

};

Complete the member functions definitions (2)

b. Given the following C++ code, answer the questions

Class TEST

{

int time;

public:

TEST( ) //Function 1

{ time=0;

cout<<”hai”;

}

~ TEST( ) //Function 2

{ cout<<”hello”;

}

void exam( ) //Function 3

{ cout<<”god bless u”;

}

TEST(int Duration) //Function 4

{ time=Duration;

cout<<”Exam starts”;

}

TEST(TEST &T) //Function 5

{ time = T.Duration;

cout<<”Exam Finished”

} };

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

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

(c) Which category of constructor Function 5 belongs to and what is the purpose of using it?

(d) Write statements that would call the member Function 1 and 4 (2)

C. class exam

{ int mark ;

char sub [ 30 ];

public :

exam ( ) Function 1

{ marks = 0 ;

strcpy ( sub , “ computer “ );

}

exam ( char s [ ] ) Function 2

{ marks = 0 ;

strcpy ( sub , s );

}

exam ( int m ) Function 3

{ marks = m ;

strcpy( sub , “ c ++ “ );

}

exam ( char s [ ] , int m ) Function 4

{

marks = m ;

strcpy ( sub , s );

} };

a. Write statements to execute all four functions ( 1 )

b. Can we over load a destructor . ( 1 / 2 )

c. What concept of OOPS is demonstrated by the four functions ( 1 / 2 )

D. Define a class ELECTION with the following specifications . Write a suitable main ( ) function also to declare 3 objects of ELECTION type and find the winner and display the details . ( 3 )

Private members :

Data : candidate_name , party , vote_received

Public members :

Functions : enterdetails ( ) – to input data

Display ( ) – to display the details of the winner

Winner ( ) – To return the details of the winner trough the object after comparing the votes received by three candidates .

E Define Constructor. (1)

3 A. class data ( 2 )

{

int num ;

public :

data ( int n )

{ num = n ; }

void show ( )

{ cout <<>

}};

class database : public data

{

char name[12];

data d ;

public :

________________________

};

Fill in the blanks to define a constructor for the derived class assigning values of the data passed from main ( ) and to assign a data 15 o base class constructor data n .

b. class RED ( 2 )

{

char n [ 20 ];

void input ( );

protected :

int x , y ;

void read ( );

public :

RED ( );

RED ( int a );

void get_red ( );

void put_red ( );

};

class WHITE : protected RED

{

void a , b ;

protected :

int c , d ;

void get_white( );

public:

WHITE ( );

Void put_white ( );

};

class BLACK : private WHITE

{

void * p ;

char st[20];

protected :

int q;

void get_black( );

public:

BLACK ( );

void put_black ( );

}ob;

  1. Name the data members and functions which are accessible by the objects of class BLACK.
  2. Give the size of object ob
  3. Name the OOPS concept implemented above and its type .
  4. Name the members accessible by function get_black( );

c. Define a class TESTMATCH in C++ with the following description :

Private Members (4)

a. Test Code of type integer

b. Description of type string

c. Noofcandidates of type integer

d. Centerreqd (number of centers required) of type integer

e. A member function CALCULATECNTR( ) to calculate and return the number of centers as (NOOFCANDIDATES /100+1)

Public Members

i. A function GETDATA() to allow user to enter values for Test Code, Description, Noofcandidates & call function CALCULATECNTR( ) to calculate the number of canters.

ii. A function PUTDATA( ) to allow user to view the content of all the data members in the following format :

TEST MATCH INFORMATION

Test Match Code: ------------

Description : --------------

Total Candidates : -----------------

Centers Required : ----------------

D. Define Constructor? How it is different than Destructor? 2

4 A.What is multiple inheritance? Explain with diagrammatic representation? 2

b. Write a program to create a text file “ TEXT.DOC “ . Tranfer the lines that start with a vowel ( not case sensitive ) to the file in reverse order . ( do not use strrev ) to a new file “EXAM.DOC” . Merge the content of both the files into a third file “ FINAL.DOC “ , contents of “TEXT.DOC” followed by “ EXAM.DOC “ . Also find the total number of bytes occupied by the file ( 4 )

c. Define a class RECORD with the following specifications and complete the class definitions . ( Use BINARY FILE CONCEPT and write the function definitions ) ( 4 )

private members :

Empno : integer

Ename : string of 30 characters

Salary : float

Input_record( ) : To accept records

Show_record( ) : To display records

Public members :

Ret_no( ) : returns eno

Create( ) : to create a file of records

Display( ) : to display the contents of the file

Modify( ) : to get a number and modify if record exist else display not found

Del( ) : to delete a record if present else say not found

5. a.Answer the questions (i) to (iv) based on the following code: 4

class MNC

{ char Cname[25];

protected: char Hoffice[25];

public : MNC();

char Country[25];

void EnterDate();

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’s constructor will be called first at the time of declaration of an object of class OUTLET.

(ii) How many bytes an object belonging to class OUTLET require?

(iii) Name the member function(s) which are accessed from the object(S) of class OUTLET.

(iv) Name the Data members which are accessible from the objects(s) of class BRANCH.

b. Consider the following class declaration: 4

class Computer

{

char chiptype[10];

int speed;

public :

void getdetails() { gets(chiptype); cin>>speed ; }

void showdetails { cout<<”Chip”< }

};

· Write the objects of Computer to a binary file.

· Read the objects of Computer from binary file and display them on screen when chiptype

has value “CD”.

c.A data file contains name and telephone number in the following format:

Johny 350456

Meeta 452144

……. ………

Where name and telephone number are separated by white space. Write a program to read the file and display the records in two columns Name and telephone number.2

6.a. Declare class height containing data members to store height of a person in feet and

inches. (4)

Add suitable member functions to:

Ø Read height of a person

Ø Display height

Ø Find and return taller out of two person’s height given as input to functions.

Ø Convert height in cms.

b. Consider the following class declaration: (4)

class Bus

{ int Bus_no;

char destination[20];

float distance; //distance in km

float time_taken; // time taken in hrs.

public:

void read ();

void write ();

void calculate (); };

Write suitable functions to:

i) Create a data file ‘Bus.dat’ by writing objects of Bus class to the binary file.

ii) Display a report showing all those buses, which visit to the specified destination.

(User defined) along with their average speed.

c. What do you mean by abstraction and polymorphism in OOP? 2

7.a Write a user define function in C++ to read the contents from a text file STORY.TXT, count and display the number of alphabets present in it. 4

b. Differentiate between default constructor and copy constructor, giving suitable ex of each.2

c. Differentiate between constructor and destructor 2

d.differentiate between structure and class 2