Sunteți pe pagina 1din 10

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 1
½ 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: 2
#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;
}
}; // error – semi-colon is missing
void main()
{
STUDENT S;
S.Input(); //error – object missing for calling function
}

½ mark for each correction


(d) bEsTOfLUck
OEsTbfcULk 3
OEsTbfcULk
1 mark for each line of correct output
DPS/Ruby Park/Computer Science Page 1 of 10 Block
Test/September/2010
(e) 100#21#51
60#11#31 2
(f) 6#8#12#
18#24#36#36# 2
1 mark for each line of correct output

ANSWER-2
(a) A static data member is known as class variable or global variable for its class. This
data member value is shared by all objects of that class. When a data member is
declared as static, only one copy of the data is maintained for all objects of the class.
Characteristics: 2
Declared inside but defined outside the class
Can be access without object
Example:
class x
{
static int count;
};
int x ::count=10;

1 mark for each correct subpart.


(b) (i) Test ob(10); //executes function-3
Test ob(10, “Delhi”); //executes function-4 2
(ii) Concept of Polymorphism through Constructor Overloading

1 mark for each correct answer.


(c) #include<iostream.h>
#include<string.h>

class Travel 4
{
long plancode;
char place[30];
int no_of_travellers;
int no_of_buses;
public:
Travel();
void show();
void newplan();
};

Travel::Travel()
{
plancode=1001;
strcpy(place,"Kolkata");
no_of_travellers=5;

DPS/Ruby Park/Computer Science Page 2 of 10 Block


Test/September/2010
no_of_buses=1;
}

void Travel::show()
{
cout<<"\n Plan Code :"<<plancode;
cout<<"\n Place :"<<place;
cout<<"\n No. of Travellers :"<<no_of_travellers;
cout<<"\n No. of Buses :"<<no_of_buses;
}

void Travel::newplan()
{
cin>>plancode;
gets(place);
cin>>no_of_travellers;
if(no_of_travellers>=40)
no_of_buses=4;
else if(no_of_travellers>=20)
no_of_buses=3;
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
(d) (i) Object of HealthClub will require 116 bytes
Object of MohanClub will require 94 bytes
(ii) Data members accessed by the HealthClub 4
Player_Name[30] , Player_Address[20], fees
Facility, F_Name[20]
(iii) Members accessed by the MohanClub
Data Members:
Player_Name[30] , Player_Address[20], fees
Member functions:
EnterClubDetails( ), ShowClubDetails( )
EnterDetails( ), ShowDetails ( )
(iv) Members which are accessible by object of HealthClub
EnterHClubDetails( )
showHClubDetails( )
EnterClubDetails( ), ShowClubDetails( )
EnterDetails( ), ShowDetails ( )

Each answer carry 1 mark

DPS/Ruby Park/Computer Science Page 3 of 10 Block


Test/September/2010
ANSWER-3
(a) void selectionsort(Employee e[], int N)
{
int i, j, pos;
float maxsal;
Employee temp;
for(i=0;i<N-1;i++)
{ 4
pos=i;
maxsal=e[i].Salary;
for(j=i+1;j<N;j++)
{
if(s[j].Salary>maxsal)
{
maxsal=s[j].Salary;
pos=j;
}
temp=e[i];
e[i]=e[pos];
e[pos]=temp;
}
}
(b) Given array MAT[15][35] stored Row-wise
No. of rows,M =15
No. of columns,N=35
Size of element =8
Base Address=B
Also given Address of MAT[5][10]=4000 4
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 Page 4 of 10 Block


Test/September/2010
1 mark for correct Base Address
1 mark for correct Adress to be calculated

(c) void stack::PUSH()


{
Book *ptr;
ptr=new Book;
if(ptr==NULL)
{ 4
cout<<"\n stack is overflows";
return;
}
cout<<"\n enter data:";
cin>>ptr->data;
gets(ptr->bname);
ptr->Next=NULL;
if(top==NULL)
ptr=top;
else
{
ptr->Next=top;
top=ptr;
}
}

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. Memory is automatically allocated and deallocated
during execution and termination of program.
Example: char str[30];

Dynamic Allocation: The amount of memory to be allocated is decided at the time of


execution. Memory is allocated and deallocated using pointers
and new and delete operator.
Example int *ptr = new int [20];

1 mark for each difference with example.


(e) Symbol Stack Operation
25,8,3 25,8,3
- 8 - 3=5
25, 5

DPS/Ruby Park/Computer Science Page 5 of 10 Block


Test/September/2010
/ 25/5=5
6 5, 6
x 30
10 30 , 10
+ 40

Result: 40

1 ½ marks for Stack and Intermediate results


½ marks for correct final result

ANSWER-4
(a) No, *p++ and ++*p are not same statements
*p++ means first use its value of (*p) and then increment p i.e. p =p+1
++*p means first increment value of (*p) and then use its value 1
Example:
int x[]={ 10, 20};
int y= *p++;
int z =++*p;
Value of y will be 10
Value of z will be 21

1 mark for difference with example


(b) Symbol Stack Operation
( (
A A
+ (, + A
B (, + AB
) AB+
* * AB+
C * AB+C 2
+ + AB+C*
D + AB+C*D
/ +,/ AB+C*D
( +,/,( AB+C*D
E +,/,( AB+C*DE
- +,/,(,- AB+C*DE
F +,/,(,- AB+C*DEF
) AB+C*DF-
; AB+C*DEF-/+

Hence expression= AB+C*DEF-/+

1 ½ mark for stack status


1 mark for correct evaluation
(c) #include<iostream.h>

DPS/Ruby Park/Computer Science Page 6 of 10 Block


Test/September/2010
#define R 10
#define C 10 3
void Sum(int A[R][C], int M, int N)
{
int sumrow=0,sumcol=0;

for(int i=0;i<N;i++)
sumcol +=A[M/2][i];

for(int j=0;j<M;j++)
sumcol +=A[j][N/2];

cout<<"\n sum of middle row "<<sumrow;


cout<<"\n sum of middle row "<<sumcol;

}
1 mark for correct function prototype
1 mark for computing middle row sum
1 mark for computing middle column sum

ANSWER-5
(a) Overloading: The methods with the same name but it differ by types of
guments and number of arguments.

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.
OR
2
In overloading, there is a relation ship between methods available in the same class
where as in Over-ridding; there is relationship between a Base class method and
Derived class method.

Overloading doesn't block inheritance from the Base class where as overridding
blocks inheritance.

In overloading, multipe methods share the same name where as in overridding, Base
class methods are redefined in the Derived class.

Overloading must have different method signatures where as overriding must have
same signature.

(b) Suppose you have two derived classes B and C that have a common base class A,
and you also have another class D that inherits from B and C. You can declare the
base class A as virtual to ensure that B and C share the same subobject of A.
2
In the following example, an object of class D has two distinct subobjects of class L,

DPS/Ruby Park/Computer Science Page 7 of 10 Block


Test/September/2010
one through class B1 and another through class B2. 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, shared by class B1 and class B2, exists.

For example:

class L { /* ... */ }; // indirect base class


class B1 : virtual public L { /* ... */ };
class B2 : virtual public L { /* ... */ };
class D : public B1, public B2 { /* ... */ };

(c) void Queue::INSERT()


{
Ticket *ptr;
ptr=new Ticket;
if(ptr==NULL)
{ 4
cout<<"\n Queue Overflows";
return;
}
cin>>ptr->Tno;
gets(ptr->Tname);
ptr->Link=NULL;
if(rear==NULL)
front=rear=ptr;
else
{
rear->Link=ptr;
rear=ptr;
}
}

void Queue::DELETE()
{

if(front==NULL)
{
cout<<"\n Queue underflows";
return;
DPS/Ruby Park/Computer Science Page 8 of 10 Block
Test/September/2010
}
Node *ptr=front;
cout<<"\n value removed"
<<ptr->Tno <<"\t"<<ptr->Tname<<endl;
front=front->Link;
delete ptr;
}
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). 1
In Packet switched network data are transmitted in discrete units of potentially
variable length blocks called packets, while in Message switching mecahnism a
node recives a message stores it untill the apporiarate route is free, then sends it
along.
Message switching sends data units that can be of any length. Packet switching
has a maximum packet size. Any message longer than that is split up into
multiple packets.

(b) Bandwidth: It is the range of frequencies that is available for the transmission of
data. For analog signal, bandwidth is expressed in Hertz (Hz) KHz, MHz, GHz
etc. For digital signals, bandwidth is expressed in terms of bits per second (bps). 1
It is the difference between the lowest and the highest frequencies transmitted.
For e.g. Cellular phones operate within the range 800-900 megahertz i.e. their
bandwidth is 100 MHz.

(c) Cookies:
A data file written to a hard drive by some Web sites, contains information
the site can use to track such things as passwords, login, registration or
identification, user preferences, online shopping cart information, and lists 2
of pages visited.
Trojan Horse:
Program that appears legitimate, but performs some illicit activity when it is
run. 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. A Trojan is similar to a virus, except that it does not replicate
itself. It stays in the computer doing its damage or allowing somebody from
a remote site to take control of the computer. Trojans often sneak in attached
to a free game or other utility

(d) Advantages:
Ease of service: easy to configure and extend network because of centralized 2
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. Simple access protocol: connection
DPS/Ruby Park/Computer Science Page 9 of 10 Block
Test/September/2010
between the central node/Hub and node.
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. Central
node dependency: if the central node fails, the entire network is rendered
inoperable.

ANSWER-7
(a) Firewall
A system designed to prevent unauthorized access to or from a private network.
Firewalls can be implemented in both hardware and software, or a combination of
both. Firewalls are frequently used to prevent unauthorized Internet users from 2
accessing private networks connected to the Internet, especially intranets. All
messages entering or leaving the intranet pass through the firewall, which examines
each message and blocks those that do not meet the specified security criteria.
Gateway
A network layer device Connects multiple networks/LANs of different protocol
Used as Proxy Server, Firewall It is the entrance node that connects a network to
other networks

(b) GPRS – General Packet Radio Service


EDGE - Enhanced Data GSM Environment, 2
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.

(c) Difference between HTML and XML


(a) HTML
HTML document formats and displays web pages’ data 2
HTML tags are predefined
HTML tags are not case-sensitive
HTML tags may not have closing tag.
(b) XML
XML documents carray data alogn with their description
XML tags are not predefined. You can create and define new tags are per your
needs
XML tags must have a closing tag.
XML tags are case-sensitive
(d) (i) Explained
(ii) Coaxial Thick Net Cable [Distance 500 metres] 4
(iii) Repeater: connect different building
Hub/Switch: In each building to connect all computers
(iv) Radio waves

DPS/Ruby Park/Computer Science Page 10 of 10 Block


Test/September/2010

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