CBSE Question Paper 2018 Class 12 Computer Science: Material Downloaded From - 1 / 40
CBSE Question Paper 2018 Class 12 Computer Science: Material Downloaded From - 1 / 40
CBSE Question Paper 2018 Class 12 Computer Science: Material Downloaded From - 1 / 40
General Instructions :
SECTION A
[Only for candidates, who opted for C++]
1. a. Write the type of C++ tokens (keywords and user defined identifiers) from the
following : (2)
i. else
ii. Long
iii. 4Queue
iv. _count
Ans.
i. keyword
ii. Identifier
iii. None
iv. Identifier
NOTE: Ignore (iii)
b. The following C++ code during compilation reports errors as follows :
Error: ‘ofstream’ not declared
Error: ‘strupr’ not declared
(i) (ii)
13@10@11@10@ 15 12
12@11@13@10@ 12@11@10@10@
AMax = 13
OR
Option [ii]
Functions 1,2,4,5 are overloaded
Reason: Function 3 and 6 not considered in this case because it would give
redeclaration error for Function 5
OR Any equivalent valid reason
OR
Option [iii]
Functions 1,2,4,6 are overloaded
Reason: Function 3 and 5 not considered in this case because it would give
redeclaration error for Function 6
OR Any equivalent valid reason
OR
Encapsulation
OR
OR
Data Hiding
OR
S.SECOND::Display() //Statement 2
c. Write the definition of a class CONTAINER in C++ with the following description :
(4)
Private Members
- Radius, Height // float
- Type // int (1 for Cone,2 for Cylinder)
- Volume // float
- CalVolume() // Member function to calculate
// volume as per the Type
1 3.14*Radius*Height
2 3.14*Radius*Height/3
Public Members
- GetValues() // A function to allow user to enter value
// of Radius, Height and Type. Also, call
// function CalVolume() from it
- ShowAll() // A function to display Radius, Height,
// Type and Volume of Container
Ans. class CONTAINER
{
void CONTAINER::CalVolume()
{
void CONTAINER::CalVolume() switch (Type)
{ {
if (Type == 1) case 1:
Volume=3.14*Radius*Height; Volume =3.14*Radius*Height;
else if (Type == 2) break;
Volume=3.14*Radius*Height/3; case 2:
} Volume=3.14*Radius*Height/3;
}
}
20 20 22 21 53
OR
25 24 23 22
20 19 18 17
15 14 13 12
10 9 8 7
OR
OR
OR
LOC(Data[I][J]) = Base(Data)+W*(NC*(I-LBR)+(J-LBC))
Taking LBR=0, LBC=0
LOC(Data[15][10]) = Base(Data)+2*(15*15+10)
15000 = Base(Data)+2*(15*15+10)
Base(Data) = 15000 - 2*(235)
Base(Data) = 15000 - 470
Base(Data) = 14530
LOC(Data[10][5])= 14530 + 2*(10*15+5)
= 14530 + 2*(155)
= 14530 + 310
= 14840
OR
LOC(Data[I][J]) = Base(Data)+W*(NC*(I-LBR)+(J-LBC))
Taking LBR=1, LBC=1
d. Write the definition of a member function AddPacket() for a class QUEUE in C++,
to remove/delete a Packet from a dynamically allocated QUEUE of Packets
considering the following code is already written as a part of the program. (4)
struct Packet
{
int PID;
char Address[20];
Packet *LINK;
};
class QUEUE
{
Packet *Front, *Rear;
public:
QUEUE(){Front=NULL;Rear=NULL;}
void AddPacket();
void DeletePacket();
~QUEUE();
};
Ans. void QUEUE::AddPacket()
{
if(Front != NULL)
{
Packet *T;
T=Front;
OR
U U
* * U
V * UV
) UV*
+ + UV*
W UV*W
- + - UV*W
Z + - UV*WZ
) + UV*WZ-
/ +/ UV*WZ-
X +/ UV*WZ-X
) UV*WZ-X/+
OR
U * V + (W - Z) / X
U U
* * U
V * UV
+ + UV*
( +( UV*
W +( UV*W
- + (- UV*W
Z + (- UV*WZ
) + UV*WZ-
/ +/ UV*WZ-
X +/ UV*WZ-X
UV*WZ-X/+
4. a. A text file named MATTER.TXT contains some text, which needs to be displayed
such that every next character is separated by a symbol ‘#’.
Write a function definition for HashDisplay() in C++ that would display the entire
content of the file MATTER.TXT in the desired format. (3)
Example :
If the file MATTER.TXT has the following content stored in it :
THE WORLD IS ROUND
The function HashDisplay() should display the following content :
T#H#E# #W#O#R#L#D# #I#S# #R#O#U#N#D#
while(F.get(ch))
cout<<ch<<'#';
F.close(); //IGNORE
}
OR
OR
void TotalTeachers()
{
ifstream F;
F.open("SCHOOLS.DAT",ios::binary);
SCHOOLS S;
while(F.read((char*)&S,sizeof(S)))
cout<<S.RNOT()<<endl;//OR S.Display();
F.close(); //IGNORE
}
OR
c. Find the output of the following C++ code considering that the binary file
SCHOOLS.DAT exists on the hard disk with the following records of 10 schools of
the class SCHOOLS as declared in the previous question (4 b). (1)
void main()
{
fstream SFIN;
SFIN.open("SCHOOLS.DAT",ios::binary | ios::in);
SCHOOLS S;
SFIN.seekg(5*sizeof(S));
SFIN.read((char*)&S, sizeof(S));
S.Display();
cout<<"Record :"<<SFIN.tellg()/sizeof(S) + 1<<endl;
SFIN.close();
}
Ans. 1004#Holy Education School#140
Record :7
SECTION B
[Only for candidates, who opted for Python]
1. a. Differentiate between Syntax Error and Run-Time Error. Also, write a suitable
example in Python to illustrate both. (2)
Ans. Syntax error : An error of language resulting from code that does not conform to
the syntax of the programming language.
Example
a = 0
while a < 10 # : is missing as per syntax
OR
d. Find and write the output of the following Python code : (2)
Data = ["P",20,"R",10,"S",30]
Times = 0
Alpha = " "
Add = 0
for C in range(1,6,2):
Times = Times + C
Alpha = Alpha + Data[C-1]+"$"
Add = Add + Data[C]
print Times, Add, Alpha
Ans. 1 20 P R R
e. Find and write the output of the following Python code : (3)
class GRAPH:
def __init__(self,A=50,B=100):
self.P1=A
self.P2=B
def Up(self,B):
self.P2 = self.P2 - B
def Down(self,B):
self.P2 = self.P2 + 2*B
def Left(self,A):
Class Top2(object):
def __init__(self,ty): #Line 3
self.Y=ty #Line 4
def ChangeY(self,ty):
self.Y=self.Y+ty
def ShowY(self):
print self.Y,
class Bottom(Top1,Top2):
def __init__(self,tz): #Line 5
self.Z=tz #Line 6
Top2.__init__(self,2*tz): #Line 7
OR
iii. What are the methods shown in Line 1, Line 3 and Line 5 known as ?
Ans. Constructors
iv. What is the difference between the statements shown in Line 6 and Line 7 ?
Ans. Initializing the member of child class in Line 6 and calling the parent class
constructor in Line 7
3. a. Consider the following randomly ordered numbers stored in a list : (3)
786, 234, 526, 132, 345, 467
Show the content of the list after the First, Second and Third pass of the bubble
sort method used for arranging in ascending order ?
Note : Show the status of all the elements after each pass very clearly
underlining the changes.
Ans.
OR
class queue:
Client=[]
def AddClient(self):
a=raw_input("Client name: ")
queue.Client.append(a)
def DeleteClient(self):
22 22
11 22, 11
/ 2
5 2, 5
10 2, 5, 10
* 2, 50
+ 52
12 52, 12
OR
4. a. Write a statement in Python to open a text file STORY.TXT so that new contents
can be added at the end of it. (1)
Ans. file= open("STORY.TXT","a") OR file.open("STORY.TXT","a")
b. Write a method in Python to read lines from a text file INDIA.TXT, to find and
display the occurrence of the word ‘‘India’’. (2)
For example :
If the content of the file is
OR
def display():
c=0
SECTION C
[For all the candidates]
TABLE : MEMBER
VNO MNAME
TABLE : TRANSACT
OR
OR
ANO ANAME
OR
ANO ANAME
101 2 2500
103 2 1000
viii. SELECT COUNT(*), SUM(AMOUNT) FROM TRANSACT
WHERE DOT <= '2017-06-01';
Ans.
2 5000
6. a. State any one Absorption Law of Boolean Algebra and verify it using truth table.
(2)
Ans. X + X . Y = X
Verification:
X Y X.Y X+X.Y
0 0 0 0
0 1 0 0
1 0 0 1
1 1 1 1
OR
X . (X + Y)= X
Verification:
X Y X.Y X. (X+Y)
0 0 0 0
0 1 1 0
1 1 1 1
OR
X + X’ . Y = X + Y
Verification:
0 0 1 0 0 0
0 1 1 1 1 1
1 0 0 0 1 1
1 1 0 0 1 1
OR
X . (X’+ Y)= X . Y
Verification:
0 0 1 1 0 0
0 1 1 1 0 0
1 0 0 0 0 0
1 1 0 1 1 1
X Y Z FN (X, Y ,Z)
0 0 0 1
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
OR
FN(X,Y,Z)= ∏ (2,3,5,6)
d. Reduce the following Boolean Expression to its simplest form using K-Map : 3
G(U,V,W,Z) = (3,5,6,7,11,12,13,15)
Ans.
OR
b. Classify each of the following Web Scripting as Client Side Scripting and Server
Side Scripting : (2)
i. Java Scripting
ii. ASP
iii. VB Scripting
iv. JSP
Ans.
i. Client Side Scripting / Server Side Scripting
ii. Server Side Scripting
iii. Client Side Scripting
iv. Server Side Scripting
c. Write the expanded names for the following abbreviated terms used in
Networking and Communications : (2)
i. SMTP
ii. VoIP
iii. GSM
iv. WLL
Ans.
i. Simple Mail Transfer Protocol
Pediatrics Unit 40
Neurology 50
Orthopedics Unit 80
OR
iii. Suggest the devices to be installed in each of these buildings for connecting
computers installed within the building out of the following : (1)
Gateway