Delhi Public School – Ruby Park, Kolkata

FIRST BLOCK TEST [2010-11] DPS/BT01/CS/01 Please check that this question paper contains 10 printed pages. Please check that this question paper contains 7 questions. [SET –B]

EXPECTED ANSWERS/VALUE POINTS COMPUTER SCIENCE (083)
ANSWER-1 (a) floor()– Math.h getc()– Stdio.h ½ mark for each correct answer (b) #define defines symbolic constants with no datatype and is a preprocessor directive whereas const is a keyword that declares a variable as a constant with datatype. Example: #define PI 3.14 const float PI = 3.14 1 mark for each correct answer (c) Corrected code: #include<iostream.h> class STUDENT { int admno; //error - data members cannot be initialized float marks; public: STUDENT() { admno=0; marks=0.0; } //error - constructor void input() { cin>>admno>>marks; } void output() cout<<admno<<marks; 1

2

{ } }; // error – semi-colon is missing void main() { STUDENT S; S.Input(); //error – object missing for calling function } (d) ½ mark for each correction bEsTOfLUck OEsTbfcULk OEsTbfcULk 1 mark for each line of correct output Page 1 of 10 Block

3

DPS/Ruby Park/Computer Science Test/September/2010

Characteristics: Declared inside but defined outside the class Can be access without object Example: class x { static int count. //executes function-3 Test ob(10. int x ::count=10. strcpy(place. void newplan(). public: Travel(). #include<iostream. int no_of_buses. (i) Test ob(10). void show().h> #include<string. “Delhi”). //executes function-4 (ii) Concept of Polymorphism through Constructor Overloading 1 mark for each correct answer. }."Kolkata").h> class Travel { long plancode. int no_of_travellers. When a data member is declared as static. }.(e) (f) 100#21#51 60#11#31 6#8#12# 18#24#36#36# 1 mark for each line of correct output 2 2 ANSWER-2 (a) A static data member is known as class variable or global variable for its class. no_of_travellers=5. only one copy of the data is maintained for all objects of the class. Travel::Travel() { plancode=1001. char place[30]. 1 mark for each correct subpart. DPS/Ruby Park/Computer Science Test/September/2010 Page 2 of 10 Block 2 (b) 2 (c) 4 . This data member value is shared by all objects of that class.

ShowDetails ( ) (iv) Members which are accessible by object of HealthClub EnterHClubDetails( ) showHClubDetails( ) EnterClubDetails( ). } void Travel::newplan() { cin>>plancode. cout<<"\n No. of Buses :"<<no_of_buses. else if(no_of_travellers>=20) no_of_buses=3. F_Name[20] (iii) Members accessed by the MohanClub Data Members: Player_Name[30] . ShowDetails ( ) Each answer carry 1 mark (d) 4 DPS/Ruby Park/Computer Science Test/September/2010 Page 3 of 10 Block . } void Travel::show() { cout<<"\n Plan Code :"<<plancode. of Travellers :"<<no_of_travellers.no_of_buses=1. Player_Address[20]. cin>>no_of_travellers. cout<<"\n Place :"<<place. ShowClubDetails( ) EnterDetails( ). else no_of_buses=2. } ½ mark for header files ½ mark for class declaration 1½ mark for newplan() function ½ mark for show() function 1 mark for constructor (i) Object of HealthClub will require 116 bytes Object of MohanClub will require 94 bytes (ii) Data members accessed by the HealthClub Player_Name[30] . if(no_of_travellers>=40) no_of_buses=4. ShowClubDetails( ) EnterDetails( ). cout<<"\n No. fees Facility. Player_Address[20]. gets(place). fees Member functions: EnterClubDetails( ).

e[i]=e[pos].j++) { if(s[j].ANSWER-3 (a) void selectionsort(Employee e[]. for(i=0.M =15 No.i<N-1. } } (b) Given array MAT[15][35] stored Row-wise No. of columns. j.j<N. int N) { int i. e[pos]=temp.Salary. pos=j.Salary. of rows. float maxsal. pos.i++) { pos=i. for(j=i+1. maxsal=e[i]. } temp=e[i]. Employee temp.Salary>maxsal) { maxsal=s[j].N=35 Size of element =8 Base Address=B Also given Address of MAT[5][10]=4000 Formula Address of A[i][j]= B + [(i-Lr)xN + (j-Lc)]]xS = B+ [(5-0)x35 +(10-0)]x8 = B + [5x35 +10]x8 = B + 185x8 4000 = B + 1480 B = 4000-1240 Hence Base Address B = 2520 Address of MAT[2][5] = 2520 + [(2-0)x35+(5-0)]x8 = 2520 + 75x8 = 2520 +600 = 3120 Hence Address of MAT[2][5] = 3120 1 mark for variables and formula 1 mark for correct substitution DPS/Ruby Park/Computer Science Test/September/2010 Page 4 of 10 Block 4 4 .

Symbol Stack Operation 25. top=ptr. else { ptr->Next=top. cin>>ptr->data. } cout<<"\n enter data:". 1 mark for each difference with example. Dynamic Allocation: The amount of memory to be allocated is decided at the time of execution.3=5 25. } } 1 mark for new node creation 1 mark for testing overflow condition 1 mark for getting data 1 mark for modifying top pointer (d) Differences between Static and Dynamic Allocation Static Allocation: The amount of memory to be allocated is decided at the time of Compilation.8. 5 Page 5 of 10 Block 4 (e) DPS/Ruby Park/Computer Science Test/September/2010 . return. Memory is allocated and deallocated using pointers and new and delete operator.3 8 .1 mark for correct Base Address 1 mark for correct Adress to be calculated (c) void stack::PUSH() { Book *ptr.8. ptr->Next=NULL.3 25. if(top==NULL) ptr=top. ptr=new Book. gets(ptr->bname). Example int *ptr = new int [20]. Memory is automatically allocated and deallocated during execution and termination of program. Example: char str[30]. if(ptr==NULL) { cout<<"\n stack is overflows".

int z =++*p. + AB ) AB+ * * AB+ C * AB+C + + AB+C* D + AB+C*D / +./ 6 x 10 + Result: 40 25/5=5 5./.(./.(.h> Page 6 of 10 Block 1 2 (c) DPS/Ruby Park/Computer Science Test/September/2010 .AB+C*DEF ) AB+C*DF. 10 40 1 ½ marks for Stack and Intermediate results ½ marks for correct final result ANSWER-4 (a) No.e. + A B (.AB+C*DE F +./.( AB+C*DE +. p =p+1 ++*p means first increment value of (*p) and then use its value Example: int x[]={ 10. AB+C*DEF-/+ Hence expression= AB+C*DEF-/+ 1 ½ mark for stack status 1 mark for correct evaluation #include<iostream. Value of y will be 10 Value of z will be 21 (b) 1 mark for difference with example Symbol Stack Operation ( ( A A + (. *p++ and ++*p are not same statements *p++ means first use its value of (*p) and then increment p i./ AB+C*D ( +. 20}. 6 30 30 .( AB+C*D E +./. int y= *p++.

i++) sumcol +=A[M/2][i]. int M. Base class methods are redefined in the Derived class. In the following example. cout<<"\n sum of middle row "<<sumrow.j<M.sumcol=0. Overriding: The methods with the same name and same number of arguments and types but one is in base class and second is in derived class. and you also have another class D that inherits from B and C. OR In overloading. Overloading must have different method signatures where as overriding must have same signature. } 1 mark for correct function prototype 1 mark for computing middle row sum 1 mark for computing middle column sum 3 ANSWER-5 (a) Overloading: The methods with the same name but it differ by types of guments and number of arguments. In overloading. (b) Suppose you have two derived classes B and C that have a common base class A. Overloading doesn't block inheritance from the Base class where as overridding blocks inheritance.i<N. an object of class D has two distinct subobjects of class L. for(int i=0.#define R 10 #define C 10 void Sum(int A[R][C]. DPS/Ruby Park/Computer Science Test/September/2010 Page 7 of 10 Block 2 2 . for(int j=0. there is relationship between a Base class method and Derived class method. You can declare the base class A as virtual to ensure that B and C share the same subobject of A. cout<<"\n sum of middle row "<<sumcol.j++) sumcol +=A[j][N/2]. int N) { int sumrow=0. there is a relation ship between methods available in the same class where as in Over-ridding. multipe methods share the same name where as in overridding.

. gets(ptr->Tname). public B2 { /* . ptr->Link=NULL. (c) void Queue::INSERT() { Ticket *ptr. ptr=new Ticket. if(rear==NULL) front=rear=ptr. return... } cin>>ptr->Tno.. } } void Queue::DELETE() { if(front==NULL) { cout<<"\n Queue underflows". rear=ptr.. DPS/Ruby Park/Computer Science Test/September/2010 Page 8 of 10 Block 4 . shared by class B1 and class B2. return.. if(ptr==NULL) { cout<<"\n Queue Overflows". class D : public B1. */ }. */ }.. else { rear->Link=ptr.one through class B1 and another through class B2. */ }. class B2 : virtual public L { /* . exists. For example: class L { /* . You can use the keyword virtual in front of the base class specifiers in the base lists of classes B1 and B2 to indicate that only one subobject of type L.. // indirect base class class B1 : virtual public L { /* . */ }.

then sends it along. (b) Bandwidth: It is the range of frequencies that is available for the transmission of data. Trojan Horse: Program that appears legitimate. Trojans often sneak in attached to a free game or other utility 1 1 (c) 2 (d) Advantages: Ease of service: easy to configure and extend network because of centralized network One device per connection: failure of individual node does not affect the other nodes Centralized Control/Problem diagnosis: failure of Network means failure of centralized hub or node. login. registration or identification. contains information the site can use to track such things as passwords. bandwidth is expressed in Hertz (Hz) KHz. bandwidth is expressed in terms of bits per second (bps). Any message longer than that is split up into multiple packets. A Trojan is similar to a virus. GHz etc. cout<<"\n value removed" <<ptr->Tno <<"\t"<<ptr->Tname<<endl. delete ptr. MHz. while in Message switching mecahnism a node recives a message stores it untill the apporiarate route is free. except that it does not replicate itself. user preferences. Message switching sends data units that can be of any length. Simple access protocol: connection DPS/Ruby Park/Computer Science Page 9 of 10 Block Test/September/2010 2 .e. and lists of pages visited. their bandwidth is 100 MHz. For analog signal. It stays in the computer doing its damage or allowing somebody from a remote site to take control of the computer. front=front->Link. It is the difference between the lowest and the highest frequencies transmitted. It may be used to locate password information or make the system more vulnerable to future entry or simply destroy programs or data on the hard disk. For digital signals. In Packet switched network data are transmitted in discrete units of potentially variable length blocks called packets. Cellular phones operate within the range 800-900 megahertz i.g. Cookies: A data file written to a hard drive by some Web sites. online shopping cart information. but performs some illicit activity when it is run. Packet switching has a maximum packet size.} Node *ptr=front. } 2 mark for each function ANSWER-6 (a) In Packet switching the packetss are stored and forwarded from primary storage (RAM) while in Message switching the message are stored and relayed from seconadary storage (disk). For e.

Gateway A network layer device Connects multiple networks/LANs of different protocol Used as Proxy Server. the entire network is rendered inoperable. (b) XML XML documents carray data alogn with their description XML tags are not predefined. especially intranets. Disadvantages: Long cable length: each node is directly connected to the center Difficult to expand: fixed number of connections/nodes per hub can be supported. which examines each message and blocks those that do not meet the specified security criteria. Firewalls are frequently used to prevent unauthorized Internet users from accessing private networks connected to the Internet.between the central node/Hub and node. or a combination of both. Central node dependency: if the central node fails. ANSWER-7 (a) Firewall A system designed to prevent unauthorized access to or from a private network.Enhanced Data GSM Environment. Difference between HTML and XML (a) HTML HTML document formats and displays web pages’ data HTML tags are predefined HTML tags are not case-sensitive HTML tags may not have closing tag. XML tags are case-sensitive (i) Explained (ii) Coaxial Thick Net Cable [Distance 500 metres] (iii) Repeater: connect different building Hub/Switch: In each building to connect all computers (iv) Radio waves 2 2 (c) 2 (d) 4 DPS/Ruby Park/Computer Science Test/September/2010 Page 10 of 10 Block . All messages entering or leaving the intranet pass through the firewall. Firewall It is the entrance node that connects a network to other networks (b) GPRS – General Packet Radio Service EDGE . Firewalls can be implemented in both hardware and software. Enhanced Data rates for Global Evolution CDMA –Code Division Multiple Access FLOSS -Free Libre and Open Source Software or to Free Livre and Open Source Software. You can create and define new tags are per your needs XML tags must have a closing tag.

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.