8
Roll No. I I I I I I I I I Code No. 1207 Second Pre-Board Examination January-2009 Class - XII Time: 3 Hours Sub. : Computer Science M.M. 70 General Instructions :- (i) All questions are compulsory (in Progromming language: C++ Q.l (a) _PolYJTIorphism is one of the major properties of OOP. How it is implemented - ~-, in C++? 2 (b) Name the header files that shall be needed for the following code: 1 void mainO chara[20]; gets(a); cout < <setw(30)< <a; getchO; [ .. (c) Rewrite the following program after removing the syntactical(s) if any. Underline each correction. $ include <stream.h> voidmainO { chara[20]; Gets(a); ifstream file("ram.txt'); file»>a; close.fileO; } (d) Find theeoutput of the following program: #include <iostream.h> int &exam( int &x, int &y) if(x>y) return y; 2 3

Second Pre Board Computer Science Kendriya Vidyalaya, No.1, Shahibaug, Ahmedabad

Embed Size (px)

DESCRIPTION

Second Pre Board Computer Science Kendriya Vidyalaya, No.1, Shahibaug, AhmedabadProvided by loookinto.blogspot.com

Citation preview

Page 1: Second Pre Board Computer Science  Kendriya Vidyalaya, No.1, Shahibaug, Ahmedabad

Roll No. I I I I I I I I I Code No. 1207

Second Pre-Board Examination January-2009Class - XII

Time: 3 Hours Sub. : Computer Science M.M. 70

General Instructions :-

(i) All questions are compulsory

(in Progromming language: C++

Q.l (a) _PolYJTIorphism is one of the major properties of OOP. How it is implemented- ~-,

in C++? 2

(b) Name the header files that shall be needed for the following code: 1

void mainO

chara[20];

gets(a);

cout <<setw(30)< <a;

getchO;

[..

(c) Rewrite the following program after removing the syntactical(s) if any.

Underline each correction.

$ include <stream.h>

voidmainO

{

chara[20];

Gets(a);

ifstream file("ram.txt');

file»>a;

close.fileO;

}

(d) Find theeoutput of the following program:

#include <iostream.h>

int &exam( int &x, int &y)

if(x>y)

return y;

2

3

Page 2: Second Pre Board Computer Science  Kendriya Vidyalaya, No.1, Shahibaug, Ahmedabad

Class - XII - Sub. : Computer Science (2)

else

return x;

voidmainO

int a=20, b=30;

exam( a,b)= -1;cout« "A =="«a «" B ="«B«endl;

exam(b,a)=7;

cout« "A == "«a++ «" B ="«b--«endl;

exam(a,b)==3;cout« "A =="«a «" B ="«b«endl;

(e) Find the output of the following program:#include <iostream.h>

class exam

public:

examO;

-examO;

void getdataO;

void putdataO;1.i,

exam::examO

{

cout«"Function 1It;

}

exam: :~examO

cout«"function 2";

voidmainO

examel,e2;

cout«" Object crea";

exame3;

cout«" END";

}

3

Page 3: Second Pre Board Computer Science  Kendriya Vidyalaya, No.1, Shahibaug, Ahmedabad

Class - XII - Sub. : Computer Science (3)

(f) In the following program, find the C01Tectpossible output(s) fromthe options:#include <stdlib.h>

#include <iostream.h>

void main()

{

randomize( );

char exam [] [10]= {"PRE I", "PRE II", PRE III", "MAIN"};. ;

int f;

fore int 1=2; 1>0; --I)

{

f == random(2) + I;

cout«exam[f]«" : ";

}

Outputs:-i) PRE I : PRE II : PRE III :

ii) PRE II: PRE III: PRE II:

iii) PRE II: PRE III: MAIN:

iv) PRE III: PRE II : PRE II :

2

r

Q.2 (a) Differentiate Multiple and multilevel inheritance in context of OOP using a

suitable example illustrating each. 2

(b) Answer the questions (i) and (ii) after going through the following program: 2class match

{

int time;

public:match( int y) { time = t; } II constructor 1match( match & t); II constructor 2

i) create an object such that it invokes constructor 1

ii) Write complete definition of constructor 2

(c) Define a class Teacher with the following class specification:

private members:name 20 characters

subject 10 charactersBasic, DA, HRA float

salary floatCalculateO function computes the salary and returns it.

salary is sum of Basic, DA and HRA

4

Page 4: Second Pre Board Computer Science  Kendriya Vidyalaya, No.1, Shahibaug, Ahmedabad

Class· XII • Sub. : Computer Science (4)

public members:

ReadDataO function accepts the data values and invoke the calculate function.

DisplayDataO function prints the data on the screen.

(d) Consider the following declarations and answer the questions given below: 4class vehicle

int wheels;

protected:

int passanger;

public:

void inputdata(int,int);

void outputdataO;

};

class heavy _vehicle:protected vehicle

{

int dieseLpetrol;

protected:

int load;

public:

void rcaddata(int,int);

void writedataO;

};

class bus: private heavy_vehicle

Name the base class and derived class of the class heavy_vehicle.

Name the data member(s) that can be accessed from function displaydata.

Name the data member(s) that can be accessed by an object of bus class.

Is the member function outputdata accessible to the objects ofheavy_vehicle class? .

{

char make[20];

public:"·

void fetchdata(char);

void displaydataO;

};

(i)

(ii)

(iii)

(iv)

I

Page 5: Second Pre Board Computer Science  Kendriya Vidyalaya, No.1, Shahibaug, Ahmedabad

Class - XII - Sub. : Computer Science (5)

Q.3 (a) Write a function in C++, which accepts an integer array and its size as parametersand swap the first half of the array with second half. Example: if an array on sixelements initially contains the elements as 4, 6, 9, 1, 3, 7 then the function

should rearrange the elements as 1,3,7,4,6,9. 3

(b) An array arr[35][15] is stored in the memory along the row with each elementoccupying 4 bytes. Find out the base address and the address of an element

arr120]I15], if the location arr[2] [2] is stored at the address 3000. 4

(c) Write a function in C++ to insert an element into a dynamically allocated stackwhere each node contains a name as data. Assume the following definition of

stack for the same. ' 4 .

struct stack

char ename[20];

stack* link;

};

(d) Write a function in C++ to print the product of each row of a 20 integer array

passed as the argument of the function.

Example: if the 20 array contains

I ~ I ~ I ~ IThen the output should appear as:Product of Row 1: 8

Product of Row 2: 18

Product of Row 3: 24

2

(e) Evaluate the following postfix expression using a stack and show the contents of

the stack after execution of each operation 2

5,11,j,8,+, 12, *,/

Q.4 (El) Differentiate seekg( ) function and tellg( ) function. 1

(b) Write a function in C++ to print the number of lines in a text file Exam.dat,starting:with letter'S'.'"

cx~----7P~J2

I

Page 6: Second Pre Board Computer Science  Kendriya Vidyalaya, No.1, Shahibaug, Ahmedabad

Class - XII - Sub. : Computer Science (6)

(c) Given a binary file student.dat, containing records of the following structuretype 3struct student

char sname[20];

int roll;

char c1assname[5];

};

Write a function in C++ that would read content from the file student.dat and

create a file class.dat copying only those records from student.dat where theclassname is either IX, X or XI.

Q.5 (a) Differentiate between cardinality and Degree of a table. 2--=~

(b) Consider the following tables. \Vrite SQL commands for the statements

(i) to (iv) and give outputs for SQL queries (v) to (viii) 6

TABLE: ITEl\tI

ITEMNO lTEMNAMEITEMQTYITEMPRICE

1101

FLOPPY150025

1102

HDISK2002350

1103

RAM 34503500

TABLE: BILL

BILLNO ITEMNOPURQTYCUST_NAMECUST CITYBIOI

1103 34RAM JAIPUR

B102

1101 45SHIVKANPUR

B103

1103 60RAMESHJAIPUR

B104

1102 23SHIVBARODA

BI05

1101 46MUKESHKANPUR

B106

1103 52PARULSIKAR

(i) To display the name of all customers from BARODA.

(ii) To display the itemname, itemqty from table item and purqty, cusCnamefrom table BILL, with their corresponding matching itemno.

(iii) To display the d'etails of all items whose itemprice is in range of 2000 and3000.

(iv) To increase the itemprice by 20% of all items.

(v) SELECT DISTINCT CITY FROM BILL;

I

Page 7: Second Pre Board Computer Science  Kendriya Vidyalaya, No.1, Shahibaug, Ahmedabad

----------------~-~-------------- ------

Class - XII - Sub. : Computer Science (7)

(vi) SELECTCOUNT(*), SUM(Pl.JRQTY) FRO~IBILLGROUPBY CUST_CITY;

(vii) SELECTITEMNAME, ITEMQTY, lTEMPRICE*4 FROM ITEM;

(viii) SELECTITEMQTY,CUST_NAMEFROMlTEM, BILL WHERE

ITEM.lTEMNO::: BILL.ITEMNO.;

Q.6 (a) State and verify Distributive law in Boolean algebra.

(b) Draw a logical circuit diagram for the following Boolean expression

a.(b'+c')

(c) Convert the following expression into its equivalent Canonical sum of

product form(SOP)

(A' +B+C') (A' + B + C) (A' + B' + C')

2

1

2

Reduce the following Boolean expression using K-·Map 3

F(x,y.z.W) =2£(1,2,4,5,6,12,13)Deline the term Bandwidth. Give unit of Bandwidth. 1

Expand the following terminologies: 1

(i) HTh1L (i i) Xiv1L

Define the term ficewalL 1

What is the importance of URL in networking? 1

Exam Industries has set up its new center at Kaka Nagar for its office and web

based activities. The company compound has 4 buildings as shown in the diagrambelow:

(d)

Q.7 a)

b)

c)

d)e)

m,

,

J

I!I

I

I~lL~:~~S;JCenter to center distances between various buildings is as follows:

~Building to Raj Building k-~om 1Raz Building to Fazz Building I 60m

·1I Jazz BuiId!ng to Ha~_shBuilding I ] 70m

Harsh Building to Fazz Buildin~. 125m Ir Raj Building to Jazz Building .. 1 90m I! ~,--,--~ ---.J

Fazz Building to Jazz Building 25m

Page 8: Second Pre Board Computer Science  Kendriya Vidyalaya, No.1, Shahibaug, Ahmedabad

Class - XII - Sub. : Computer Science (8)

Number of Computers in each of the buildings is follows:

Harsh Building 15

Raj Building

150

Fazz Building

15

Jazz Bulding

25

e 1 ) Suggest a cable layout of connections between the buildings. 1

e2) Suggest the most suitable place (i.e. building) to house the server of this

organisation with a suitable reason. 1

e3) Suggest the placement ofthe following devices with justification: 1(i) Internet Connecting Device/Modem

(ii) Switch

e4) The organisation is planning to link its sale counter situated in various parts ofthe same city, which type of network out of LAN, MAN or WAN will be formed?..Justify your answer.' 1

~~'",)4:> L-", 1:>.(>v

, ?"

KVS(AR)