CS201 Final term Examination Spring 2010

No Comments

Question No: 1      ( Marks: 1 ) - Please choose one
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      ( Marks: 1 ) - Please choose one
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      ( Marks: 1 ) - Please choose one
To access the data members of structure _______ is used.

       ► dot operator (.)
       ► * operator
       ►  operator
       ► None of given.


Question No: 4   ( Marks: 1 ) - Please choose one
eof( ), bad( ), good( ), clear( ) all are manipulators.

       ► True
       ► False


Question No: 5      ( Marks: 1 ) - Please choose one
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


Question No: 6      ( Marks: 1 ) - Please choose one
The return type of operator function must always be void.

       ► True
       ► False


Question No: 7      ( Marks: 1 ) - Please choose one
Friend function of a class is ______________ .

       ► Member function
       ► Non-member function
       ► Private function
       ► Public function


Question No: 8      ( Marks: 1 ) - Please choose one
Function implementation of friend function must be defined outside the class.

       ► True
       ► False


Question No: 9      ( Marks: 1 ) - Please choose one
The normal source of cin object is,

       ► File
       ► Disk
       ► Keyboard
       ► RAM


Question No: 10      ( Marks: 1 ) - Please choose one
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;


Question No: 11      ( Marks: 1 ) - Please choose one
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      ( Marks: 1 ) - Please choose one
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      ( Marks: 1 ) - Please choose one
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      ( Marks: 1 ) - Please choose one
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      ( Marks: 1 ) - Please choose one
Heap is constantly changing in size.

       ► True
       ► False


Question No: 16      ( Marks: 1 ) - Please choose one
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      ( Marks: 1 ) - Please choose one
Classes defined inside other classes are called ________ classes

       ► looped
       ► nested
       ► overloaded
       ► none of the given options.


Question No: 18      ( Marks: 1 ) - Please choose one
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 replaced
       ► None of the given options
       ► Remain constant.
       ► can be changed by some operation


Question No: 19      ( Marks: 1 ) - Please choose one
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 correctly
       ► Destructors do not return a value.


Question No: 20      ( Marks: 1 ) - Please choose one
Every class contains _______________.

       ► Constructor
       ► Destructor
       ► Both a constructor and a destructor
       ► None of the given options


Question No: 21      ( Marks: 1 ) - Please choose one
A template function must have

       ► One or more than one arguments
       ► Only one argument
       ► Zero arguments
       ► None of the given options


Question No: 22      ( Marks: 1 ) - Please choose one
Structured Query Language is used for ______________

       ► Databases Management
       ► Networks
       ► Writing Operating System
       ► none of the given options


Question No: 23      ( Marks: 1 ) - Please choose one
When a call to a user-defined function finishes, the variable defined inside the function is still in existence.

       ► True
       ► False


Question No: 24      ( Marks: 1 ) - Please choose one
The precedence of an operator can be changed through operator overloading.

       ► True
       ► False


Question No: 25      ( Marks: 1 ) - Please choose one
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


Question No: 26      ( Marks: 1 ) - Please choose one
"delete" operator is used to return memory to free store, which is allocated by the "new" operator.

       ► True
       ► False


Question No: 27      ( Marks: 2 )

What is the difference between switch statement and if statement.


Question No: 28      ( Marks: 2 )
How can we initialize data members of contained object at construction time?


Question No: 29      ( Marks: 2 )
How the data members of a class are initialized with meaningful values?


Question No: 30      ( Marks: 2 )
Can we overload new and delete operators?


Question No: 31      ( Marks: 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      ( Marks: 3 )
What is the keyword ‘this’ and what are the uses of ‘this’ pointer?


Question No: 33      ( Marks: 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      ( Marks: 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      ( Marks: 5 )
Write down the disadvantages of the templates.


Question No: 36      ( Marks: 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

Next PostNewer Post Previous PostOlder Post Home

0 comments

Post a Comment