We are Permanently Move to www.VUpk.net Please Join us there.

CS201 Final Term Paper Solved 2010 - 2

Friday 3 August 2012
FINALTERM  EXAMINATION
Spring 2010
CS201- Introduction to Programming


M a r k s: 58 
Question No: 1      ( M a r k s: 1 ) http://vuzs.net 
In if structure the block of statements is executed only,
       ► When the condition is false
       ► When it contain arithmetic operators
       ► When it contain logical operators
       ► When the condition is true 
Question No: 2      ( M a r k s: 1 ) http://vuzs.net
Header file: fstream.h includes the definition of the stream classes __________.
       ► ifstream, fstream, cout
       ifstream, fstream, ofstream
       ► fstream, cin, cout
       ► None of the above
Question No: 3      ( M a r k s: 1 ) http://vuzs.net 
To access the data members of structure _______ is used.
       ► dot operator (.)
       ► * operator
       ►  operatorà
       ► None of given. 
Question No: 4      ( M a r k s: 1 ) http://vuzs.net 
eof( ), bad( ), good( ), clear( ) all are manipulators.
       True
       False 
Question No: 5      ( M a r k s: 1 ) http://vuzs.net 
Which kind of functions can access private member variables of a class?
       Friend functions of the class
       ► Private member functions of the class
       ► Public member functions of the class
       ► Friend, private and public functions
Rational:

By default any class function either its public or private has access to its private variable. 
Only these private members are not accessible by function of other class.
Only friend function has special privilege that it has access to any private variable of its friend class.
If we take option No.1 as correct then it will negate the very basic rule of class definition.
As we know that any variable with in the class by default is a private variable, which can be used in the public and private functions of that class freely.
Our Question does not speak about the outer classes, it  points only to function level that which kind of function can access the private variable.
(zubair, vuzs.jul2011)
Question No: 6      ( M a r k s: 1 ) http://vuzs.net
The return type of operator function must always be void.
       ► True
       ► False
Question No: 7      ( M a r k s: 1 ) http://vuzs.net
Friend function of a class is ______________ .
       ► Member function
       Non-member function             
       ► Private function
       ► Public function

Question No: 8      ( M a r k s: 1 ) http://vuzs.net
Function implementation of friend function must be defined outside the class.
       ► True
       ► False (any where in the class)
Question No: 9      ( M a r k s: 1 ) http://vuzs.net 
The normal source of cin object is,
       ► File
       ► Disk
       ► Keyboard
       ► RAM
Question No: 10      ( M a r k s: 1 ) http://vuzs.net
Which of the following is correct way to initialize a variable x of int type with value 10?
       ► int x ; x = 10;
       ► int x = 10;
       ► int x, x = 10;
       ► x = 10; http://groups.google.com/group/vuZs/
Question No: 11      ( M a r k s: 1 ) http://vuzs.net 
Consider the following code segment. What will be the output of the following program?
int func(int) ;
int num = 10 ;
int main(){
int num ;
num = 5 ;
cout << num ;
cout << func(num) ;
}
int func(int x){
return num ;
}
       ► 5, 5  
       ► 10, 5
       ► 5, 10 
       ► 10, 10
Question No: 12      ( M a r k s: 1 ) http://vuzs.net 
With template function, the compiler automatically detects the passed data and generates a new copy of function using passed data.
       ► True
       ► False
Question No: 13      ( M a r k s: 1 ) http://vuzs.net
What will be the correct syntax to declare two-dimensional array of float data type?
       ► float arr{2}{2} ;
       ► float arr[2][2] ;
       ► float arr[2,2] ;
       ► float[2][2] arr ;   
Question No: 14      ( M a r k s: 1 ) http://vuzs.net
The first parameter of operator function for << operator,
       ► Must be passed by value
       ► Must be passed by reference
       ► Can be passed by value or reference
       ► Must be object of class 
Question No: 15      ( M a r k s: 1 ) http://vuzs.net
Heap is constantly changing in size.
       ► True
       ► False

Question No: 16      ( M a r k s: 1 ) http://vuzs.net
While calling function, the arguments are assigned to the parameters from
       ► left to right.
       ► right to left 
       ► no specific order is followed
       ► none of the given options.
Question No: 17      ( M a r k s: 1 ) http://vuzs.net
Classes defined inside other classes are called ________ classes
       ► looped
       ► nested
       ► overloaded
       ► none of the given options.
Question No: 18      ( M a r k s: 1 ) http://vuzs.net
If we define an identifier with the statement #define PI 3.1415926 then during the execution of the program the value of PI __________
       ► can not be replace
       ► None of the given options
       ► Remain constant.
       ► can be changed by some operation 
Question No: 19      ( M a r k s: 1 ) http://vuzs.net 
Which value is returned by the destructor of a class?
       ► A pointer to the class.
       ► An object of the class.
       ► A status code determining whether the class was destructed correctl
       Destructors do not return a value.
Question No: 20      ( M a r k s: 1 ) http://vuzs.net 
Every class contains _______________.
       ► Constructor
       ► Destructor
       ► Both a constructor and a destructor
       ► None of the given options
Question No: 21      ( M a r k s: 1 ) http://vuzs.net
A template function must have
       ► One or more than one arguments
       ► Only one argument
       ► Zero argument
       ► None of the given options 

Question No: 22      ( M a r k s: 1 ) http://vuzs.net 
Structured Query Language is used for ______________
       ► Databases Management
       ► Networks
       ► Writing Operating System
       ► none of the given options
Question No: 23      ( M a r k s: 1 ) http://vuzs.net 
When a call to a user-defined function finishes, the variable defined inside the function is still in existence.
       ► True
       False
Question No: 24      ( M a r k s: 1 ) http://vuzs.net 
The precedence of an operator can be changed through operator overloading.
       ► True
       ► False
Question No: 25      ( M a r k s: 1 ) http://vuzs.net
A Matrix can be composed of ints, floats or doubles as their elements. Best way is to handle this , _______________
       ► Write a separate class to handle each
       Use templates
       ► Use strings to store all types
       ► None of the given options
A Matrix can be composed of ints, floats or doubles as their elements. Instead of handling these data types separately, we can write Matrix class as a template class and write code once for all native data types.
Write Matrix class as a template class and write code once for all native data types
Question No: 26      ( M a r k s: 1 ) http://vuzs.net
"delete" operator is used to return memory to free store, which is allocated by the "new" operator.
       ► True
       ► False
Question No: 27      ( M a r k s: 2 )
What is the difference between switch statement and if statement.
Question No: 28      ( M a r k s: 2 ) 
How can we initialize data members of contained object at construction time?
Question No: 29      ( M a r k s: 2 ) 
How the data members of a class are initialized with meaningful values?
Question No: 30      ( M a r k s: 2 )
Can we overload new and delete operators?
Question No: 31      ( M a r k s: 3 )
What will be the output of following functions if we call these functions three times?
1)
void func1(){
int x = 0;
x++;
cout << x << endl;
}
2)
void func2(){
static int x = 0 ;
x++;
cout << x << endl ;
 
Question No: 32      ( M a r k s: 3 )
 What is the keyword ‘this’ and what are the uses of ‘this’ pointer?
Question No: 33      ( M a r k s: 3 )
Suppose an object of class A is declared as data member of class B.
(i) The constructor of which class will be called first?
(ii) The destructor of which class will be called first?
Question No: 34      ( M a r k s: 5 )
Write the general syntax of a class that has one function as a friend of a class along with definition of friend function.
Question No: 35      ( M a r k s: 5 )
Write down the disadvantages of the templates.
Question No: 36      ( M a r k s: 5 ) 
Write a program which defines five variables which store the salaries of five employees, using setw and setfill manipulators to display all these salaries in a column.
Note: Display all data with in a particular width and the empty space should be filled with character x
Output should be displayed as given below:
xxxxxx1000
xxxxxx1500
xxxxx20000
xxxxx30000
xxxxx60000

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...