ASSESSMENT - I: 2014-2015 Class: Xii Computer Science: General Instructions
ASSESSMENT - I: 2014-2015 Class: Xii Computer Science: General Instructions
ASSESSMENT - I : 2014-2015
Time allowed:3 Hours CLASS: XII COMPUTER SCIENCE M. Marks: 70
General Instructions:
Check that you have the correct question paper.
The marks for individual questions are shown in round brackets: e.g. (2).
You are reminded of the importance of clear English and careful presentation in your
answers.
You may use a soft pencil for any diagrams, or rough working.
At the end of the examination, fasten all your work securely together.
15 minutes time has been allotted to read this question paper. Students will read the
question paper only and will not write any answer on the answer-book during this
period.
You must ensure that the answers to parts of questions are clearly labelled.
There are VIII questions with sub divisions in this question paper.
I. a) Give the differences between actual parameters and formal parameters?. Also give a suitable C++ code to
illustrate both. (2)
b) Which C++ header file(s) are essentially required to be included to run/execute the following C++ source
code? ( Note: Do not include any header file(s) , which is/are not required). (1)
void main()
{
char TIPS[]=”Don’t look where you fall, look where you slip”;
for(int i=0; i<strlen(TIPS); i++)
getch();
Page 1 of 12
c) Observe the following program and find out, which output(s) out of (i) to (iv) will be expected from the
program? Justify your answer. (2)
#include<iostream.h>
#include<stdlib.h>
void main( )
{
randomize( );
int Mynum, max=5;
Mynum = 20 + random(max);
for(int N=Mynum; N<=25; N++)
cout<<N<<”*”;
}
Options
i) 20*21*22*23*24*25
ii) 22*23*24*25*
iii) 23*24*
iv) 21*22*23*24*25*
d) Rewrite the following program after removing all the syntactical errors (if any). Underline each correction.
(2)
include<iostream>
typedef shar[80] String;
void main()
{
String S = “Peace”;
int L = strlen(S);
cout<<S<<”has’<<L<<characters<<endl;
}
#include<iostream.h>
#include<ctype.h>
void Encryption( char CH[], int M);
void main()
{
char Text[]="BEHAPPYALWAYS";
Encryption(Text, 1);
cout<<Text;
Page 2 of 12
}
#include<iostream.h>
#include<conio.h>
void main()
{
int A[]={1001,2001,3001,4001};
output(++A[0], --A[0], A[0]++);
output(--A[0], ++A[0], --A[0]);
}
II. a) Enlist the differences between data encapsulation and data abstraction. (2)
b) Name the Object Oriented features implemented in the following C++ code: (2)
class WestWorldSchool
{
private:
char Stu_Name[20];
char Gender;
protected:
int Expected_Mark_Project;
int Expected_Mark_Practical;
Page 3 of 12
int Expected_Mark_Theory;
public:
int Expected_Mark_Total;
void INPUT(); // To input the data member details except Expected_Mark_Theory
void SHOW(); // To display data member details on screen
void CALCULATE(); // To calculate Expected_Mark_Total of all students
void CALCULATE(char Gen);// To calculate Expected_Mark_Total of Boys.
WestWorldSchool(); // To assign initial values for the data members.
};
b) Identify the FDs selected for FCs during compile time from the following C++ program: (2)
FD Function Definition
FC Function Call
#include<iostream.h>
#include<conio.h>
void main()
{
callme(4,66); // FC 1
callme('a',44); // FC 2
callme(77.334); // FC 3
callme(6.33); // FC 4
callme(65.33L); // FC 5
getch();
}
FTpe Sticker
Vegetarian GREEN
Eggtarian YELLOW
Non-Vegetarian RED
Public Members:
A function GetFood() to allow user to enter values for FoodCode, Food, FType and call function
GetSticker() to assign Sticker.
A function ShowFood() to allow user to view the content of all the data members.
#include<iostream.h>
#include<conio.h>
class METRO
{
int Mno;
int Tripno;
int Passengercount;
public:
METRO(int Tmno =1)
{
Mno=Tmno;
Tripno=0;
Passengercount=0;
}
void Trip( int PC=20)
Page 5 of 12
{
Tripno++;
Passengercount+=PC;
}
void Status()
{
cout<<Mno<<”:”<<Tripno<<”:”<<Passengercount<<endl;
}
};
void main()
{
METRO M(5), T;
M.Trip();
T.Trip(50);
M.Status();
M.Trip(30);
T.Status();
M.Status();
}
c) When can you make a member function as an inline member function? What is the advantage of an inline
function? (1)
d) Rewrite the following program after removing syntactical error(s) if any. Underline each correction (2)
#include <iostream.h>
#include <stdio.h>
class XLOG
{
int Parcel_Number;
char Customer[25]=”XLM”;
char Content[20];
public:
void Display()
{
cout<<Parcel_Number<<Customer<<Content<<”\n”;
}
};
void main()
{
Page 6 of 12
XLOG NEW;
NEW.Register_Parcel(00968, “Rooney”);
Display();
getch();
}
f) List any two characteristics a static data members with respect to Object Oriented Programming. (1)
V. a) Answer the questions (i) to (iv) after going through the following class: (4)
class Substitution
{
char Teacher_Absent[20];
int Lesson_No;
char Substitute[20];
char Date[10];
public:
Substitution() //Function 1
{
cin>>Teacher_Absent;
cin>>Lesson_No;
cin>>Substitute;
cin>>Date;
cout<<”Substitution Arranged”;
}
~Substitution() //Function 2
{
cout<<”Substitution Cancelled”;
}
};
i) In Object Oriented Programming, what are Function 1 and Function 4 combined together referred
as?
ii) In Object Oriented Programming which concept is illustrated by Function 2? When is this function
called / invoked?
Page 7 of 12
iii) In Object Oriented Programming, what is the name of Function 3? Write a line of code to call /
invoke
this function.
iv) Write a line of code to call Function 4.
b) What is the difference between implicit call and explicit call with respect to constructor functions? Give a
C++ example to illustrate both. (3)
c) What is the need for a copy constructor function in a class? Enlist the two situations where copy constructor
called / invoked (3)
VI. a) Answer the questions (i) to (iv) based on the following: (4)
class CUSTOMER
{
int Cust_no;
char Cust_Name[20];
protected:
void Register();
public:
CUSTOMER();
void Status();
};
class SALESMAN
{
int Salesman_no;
char Salesman_Name[20];
protected:
float Salary;
public:
SALESMAN();
void Enter();
void Show();
};
(i) Write the names of member functions which are accessible from objects belonging to class CUSTOMER.
(ii) Write the names of all the member functions which are accessible from objects belonging to class
SALESMAN.
(iii) Write the names of all the data members which are accessible from member functions of class SHOP.
(iv) How many bytes will be required by an object belonging to class SHOP and CUSTOMER?
Page 8 of 12
b) Define the following terms: (3)
i) Virtual Base class
ii) Base class
iii)Abstract Base class
c) What will be displayed on screen, when the object NN goes out with respect to the following code: (3)
class Nana
{
public:
Nana()
{
cout<<” Retirement is not a finishing line \n”;
}
~Nana()
{
cout<<” It is a Refreshing start \n”;
}
};
~Nani()
{
cout<<” So Alive all my Life \n”;
}
};
~NanaNani()
{
cout<<”Smile for ever\n”;
}
};
void main()
{
Page 9 of 12
NanaNani NN;
}
VII. a) Write an user defined function that count the number of independent words ‘like’ from a text file
LINES.TXT. (3)
I like people like you who like others like me and make others like me to like others like you
The output is 7
b) A garage specializes in selling second hand cars. A binary file GARAGE.dat is used to store information
on the cars for sale. The file contains records/objects of the class GARAGE, which is defined below.
class GARAGE
{
char Make[20];
char Model[20};
char Color;
int Number_of_Doors;
char Registration_Number;
float price;
public:
void Display()
{
cout<<Make<<”#”<<Model<<”#”<<Color<<”#”<<Number_of_Doors<<”#”<<endl;
}
char* GetColor()
{
return color;
}
};
Write a function in C++, to search and display the details of cars, which have “green” color from the binary
file GARAGE.dat. (4)
d) Observe the program segment given below carefully and answer the questions that follow: (1)
class Stock
{
int Ino;
int Qty;
char Item[20];
public:
Page 10 of 12
void Enter()
{
cin>>Ino;
gets(Item);
cin>>Qty;
}
void Issue(int Q)
{
Qty + = Q;
}
void purchase(int Q)
{
Qty - = Q;
}
int Getinfo()
{
return Ino;
}
};
i) Write Statement 1 to position the file pointer to the appropriate place, so that the data updating is
done for the required item.
ii) Write Statement 2 to perform the write operation so that the updating is done in the binary file.
Page 11 of 12
VIII. a) Find the output of the following program: (4)
#include<iostream.h>
void main()
{
int *Queen, Moves[] = { 11, 22, 33, 44};
Queen = Moves;
Moves[2]+=22;
cout<<”Queen @”<<*Queen<<endl;
*Queen-=11;
Queen+=2;
cout<<”Now @”<<*Queen<<endl;
Queen++;
cout<<”Finally @”<<*Queen<<endl;
cout<<”New Origin @”<<Moves[0]<<endl;
}
Page 12 of 12