vuZs

Virtual University: Study Resource Bank

You are here: Home Old Papers CS201 - Introduction to Programming Papers CS201- FINAL 2010 shared by Salman Solved by vuZs Team
Like this Page? Press  
 

Solved Exam papers

CS201- FINAL 2010 shared by Salman Solved by vuZs Team

FINALTERM  EXAMINATION
Spring 2010
CS201- Introduction to Programming
Solved by Farhat Qudsia & Zuabir Hussain
vuZs Team
www.vuzs.net

M - 58 
Question No: 1      ( M - 1 ) . 
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 - 1 ) .
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 - 1 ) . 
To access the data members of structure _______ is used.
       ► dot operator (.)
       ► * operator
       ►  operatorà
       ► None of given. 
Question No: 4      ( M - 1 ) . 
eof( ), bad( ), good( ), clear( ) all are manipulators.
       True
       False 
Question No: 5      ( M - 1 ) . 
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 - 1 ) .
The return type of operator function must always be void.
       ► True
       ► False
Question No: 7      ( M - 1 ) .
Friend function of a class is ______________ .
       ► Member function
       Non-member function             
       ► Private function
       ► Public function
Question No: 8      ( M - 1 ) .
Function implementation of friend function must be defined outside the class.
       ► True
       ► False (any where in the class)
Question No: 9      ( M - 1 ) . 
The normal source of cin object is,
       ► File
       ► Disk
       ► Keyboard
       ► RAM
Question No: 10      ( M - 1 ) .
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 - 1 ) . 
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 - 1 ) . 
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 - 1 ) .
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 - 1 ) .
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 - 1 ) .
Heap is constantly changing in size.
       ► True
       ► False
Question No: 16      ( M - 1 ) .
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 - 1 ) .
Classes defined inside other classes are called ________ classes
       ► looped
       ► nested
       ► overloaded
       ► none of the given options.
Question No: 18      ( M - 1 ) .
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 - 1 ) . 
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 - 1 ) . 
Every class contains _______________.
       ► Constructor
       ► Destructor
       ► Both a constructor and a destructor
       ► None of the given options
Question No: 21      ( M - 1 ) .
A template function must have
       ► One or more than one arguments
       ► Only one argument
       ► Zero argument
       ► None of the given options 
http://groups.google.com/group/vuZs/
Question No: 22      ( M - 1 ) . 
Structured Query Language is used for ______________
       ► Databases Management
       ► Networks
       ► Writing Operating System
       ► none of the given options
Question No: 23      ( M - 1 ) . 
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 - 1 ) . 
The precedence of an operator can be changed through operator overloading.
       ► True
       ► False
Question No: 25      ( M - 1 ) .
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 - 1 ) .
"delete" operator is used to return memory to free store, which is allocated by the "new" operator.
       ► True
       ► False
Question No: 27      ( M - 2 )
What is the difference between switch statement and if statement.
Question No: 28      ( M - 2 ) 
How can we initialize data members of contained object at construction time?
Question No: 29      ( M - 2 ) 
How the data members of a class are initialized with meaningful values?
Question No: 30      ( M - 2 )
Can we overload new and delete operators?
Question No: 31      ( M - 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 - 3 )
 What is the keyword ‘this’ and what are the uses of ‘this’ pointer?
Question No: 33      ( M - 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 - 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 - 5 )
Write down the disadvantages of the templates.
Question No: 36      ( M - 5 ) http://www.vuzs.net/
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
 

 

Add comment


Security code
Refresh

You are here: Home Old Papers CS201 - Introduction to Programming Papers CS201- FINAL 2010 shared by Salman Solved by vuZs Team

About Author