CS201 - Word Document

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 55

CS201- Introduction to Programming

Latest Solved Mcqs from Final term July 11,2011


Papers
Mc100401285 [email protected] Moaaz
Siddiq Bc100400662 Latest Mcqs
[email protected] Asad Ali

1
FINALTERM EXAMINATION 2011
CS201- Introduction to Programming

Question No: 1 ( Marks: 1 ) - Please choose one


All A template function must have at least--------generic data type

► Zero
► One
► Two
► Three

Question No: 2 ( Marks: 1 ) – Please choose one


Which of the following statement is best regarding declaration of friend function?

► Friend function must be declared after public keyword


. ► Friend function must be declared after private keyword.
► Friend function must be declared at the top within class definition.
► It can be declared anywhere in class as these are not affected by the public and private keywords.

Question No: 3 ( Marks: 1 ) - Please choose one


Which one of the following is the declaration of overloaded pre-increment operator implemented as
member function?

► Class-name operator +() ;


► Class-name operator +(int) ;
► Class-name operator ++() ;
► Class-name operator ++(int) ;

Question No: 4 ( Marks: 1 ) - Please choose one


Class is a user defined .

► data type
► memory referee
► value
► none of the given options.

Question No: 5 ( Marks: 1 ) - Please choose one


How many bytes will the pointer intPtr of type int move in the following statement? intPtr += 3 ;

2
► 3 bytes
► 6 bytes
► 12 bytes
► 24 bytes

Question No: 6 ( Marks: 1 ) - Please choose one


Which of the following is the correct C++ syntax to allocate space dynamically for an array of 10 int?

► new int(10) ;
► new int[10] ;
► int new(10) ;
► int new[10];

Question No: 7 ( Marks: 1 ) - Please choose one


A Pointer is a special variable that contain

► Data values
► Memory Address
► Both data and values
► None of the given option

Question No: 8 ( Marks: 1 ) - Please choose one


Reference Value Type Data The code is written to the program.

► implement
► design
► analysis
► none of the given options

FINALTERM EXAMINATION
CS201 - Introduction to programming
Final Term Spring 2010

Operator overloading can be performed through .


► Classes
► Function
► Operators
► Reference

Question No: 2 ( Marks: 1 ) - Please choose one


When a value is referred by a normal variable then it is known as,

► Direct Reference
►Indirect Reference.
3
► Partial Reference
► Proper Reference

When a value is referred by a normal variable is known as direct reference


Question No: 3 ( Marks: 1 ) - Please choose one
Which of the following function is used to increase the size of already allocated memory chunk?

► malloc
► calloc
► realloc
► free

Question No: 4 ( Marks: 1 ) - Please choose one


Which of the following is NOT a preprocessor directive?

► #error
► #define
► #line
► #ndefine

Question No: 5 ( Marks: 1 ) – Please choose one


The stream objects cin and cout are included in which header file?

► iostream.h
► fstream.h
► istream.h
► ostream.h

Question No: 6 ( Marks: 1 ) – Please choose one


Overloaded delete operator function takes the same parameter as an argument returned by new
operator function.

► True
► False

The same pointer that is returned by the new operator, is passed as an argument to the delete
operator. These rules apply to both, if operators (new and delete) are overloaded as member or non-
member operators (as global operators).

Question No: 7 ( Marks: 1 ) – Please choose one


When an array of object is created dynamically then there is no way to provide parameterized
constructors for array of objects.

► True
► False

Question No: 8 ( Marks: 1 ) – Please choose one


4
C is widely known as development language of _ operating system.
► Linux
► Windows
► Unix
► Mac OS
In the start C became widely known as the development language of the UNIX operating system,
and the UNIX operating system was written by using this C language. The C language is so
powerful that the compiler of C and other various operating systems are written in C.

Question No: 9 ( Marks: 1 ) - Please choose one


Computer can understand only machine language code.

► True
► Fals
e

Question No: 10 ( Marks: 1 ) - Please choose one


We can not define a function as a friend of a Template class.

► True
► False

Class templates can have friends. A class or class template, function, or function template can be a
friend to a template class. Friends can also be specializations of a class template or function template,
but not partial specializations.

Question No: 11 ( Marks: 1 ) – Please choose one


What will be the value of ‘a’ and ‘b’ after executing the following statements?
A = 3;
b = a++;

► 3, 4
► 4, 4
► 3, 3
► 4, 3

Question No: 12 ( Marks: 1 ) – Please choose one


Consider the following code segment. What will be the output of following
code? Int addValue (int *a){
int b = (*a) +
2; return b ;
}
main () {
int x =6
;
cout << x << “,” ;
cout << addValue(&x) <<
“,” ; cout << x ;}
5
► 6,8,6
► 6,6,8
► 6,8,8
► 6,6,6

Question No: 13 ( Marks: 1 ) – Please choose one


is used to trace the logic of the program and correct the logical errors.
► Compiler
► Editor
► Linker
► Debugger (Page 13)

Question No: 14 ( Marks: 1 ) - Please choose one


new and delete are whereas malloc and free are .

► Functions, operators
► Classes, operators
► Operators, functions (Page 342-285)
► Operators, classes

Hence, we can call new and delete operators, P# 342


we have allocated a memory space for our use by malloc function. P# 285

Question No: 15 ( Marks: 1 ) - Please choose one


Like member functions, can also access the private data members of a class.

► Non-member functions
► Friend functions (Page 346)
► Any function outside class
► None of the given options

Question No: 16 ( Marks: 1 ) – Please choose one


Which situation would require the use of a non-member overloaded operator?

► The overloaded operator is an Assignment operator.


► The left most operand is an object of a class.(Page 375)
► The left operand is built-in data type.
► The operator returns a reference.

When an operator function is implemented as a non-member function, the left-most operand


may be an object of the operator’s class, an object of a different class, or a built-in type

Question No: 17 ( Marks: 1 ) - Please choose one


The stream insertion and stream extraction operators are already overloaded for .
► User-defined data types
► Built-in data types http://www.sstutor.com/cpp/stream1.htm
► User-defined and built-in data types
► None of the given options
6
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. (Page 271)
► can be changed by some operation

Question No: 19 ( Marks: 1 ) - Please choose one


Assignment operator is-----------------------associative.

► right
► left
► binary
► unary

Question No: 20 ( Marks: 1 ) - Please choose one


When ever dynamic memory allocation is made in C/C++, it is freed .

► Explicitly
► Implicitly
► Both explicitly and implicitly
► None of the given options

Question No: 21 ( Marks: 1 ) – Please choose one


The appropriate data type to store the number of rows and colums of the matrix is .
► float
► int (Not sure)
► char
► none of the given options.

Question No: 22 ( Marks: 1 ) – Please choose one


Which of the following function do NOT initialize the chunk of memory to all zero?

► calloc() function
► Both malloc() and calloc()
► None of the above
► malloc() function

The malloc function differs from calloc in the way that the space allocated by malloc is not initialized
and contains any values initially.

Question No: 23 ( Marks: 1 ) – Please choose one


The function free() returns back the allocated memory got thorough calloc and
7
malloc to .

► stac
k
► heap
► stack and heap
► None of the given options

Question No: 24 ( Marks: 1 ) – Please choose one


width() is member function of

► cin object
► cout object
► Both cin and cout object
► None of the given option

Question No: 25 ( Marks: 1 ) - Please choose


one Templates are not type safe.

► true
► false

Templates are type-safe. This is because the types that templates act upon are known at compile time,
so the compiler can perform type checking before errors occur.

Question No: 26 ( 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
FINALTERM EXAMINATION
Spring 2010
CS201- Introduction to Programming

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 .
8
► 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


9
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] ;
10
► 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.


11
► 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
http://en.wikipedia.org/wiki/Template_%28programming
%29

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
12
► Use strings to store all types
► None of the given options

13
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

FINALTERM EXAMINATION
Spring 2010
CS201- Introduction to Programming

Question No: 1 ( Marks: 1 ) - Please choose one


Pointer is a variable which store,

► Data
► Memory Address
► Data Type
► Values

Question No: 2 ( Marks: 1 ) - Please choose one


All preprocessor directives are started with the symbol .

►*
►+
►@
►#

Question No: 3 Marks: 1 ) - Please choose one

Within the statement obj1=obj2; obj1 will call the assignment operator function and obj2 will be
passed as an argument to function.

► True
► Fals
e

Question No: 4 ( Marks: 1 ) - Please choose one


What is the sequence of event(s) when deallocating memory using delete operator?

► Only block of memory is deallocated for objects


► Only destructor is called for objects
► Memory is deallocated first before calling destructor
► Destructor is called first before deallocating memory

Question No: 5 ( Marks: 1 ) - Please choose one


14
The second parameter of operator functions for << and >> are objects of the class for which we are

15
overloading these operators.

► True
► False

Question No: 6 ( Marks: 1 ) - Please choose one


To include code from the library in the program, such as iostream, a directive would be called up using
this command.

► #include “iostream.h”
► include <iostream.h>
► include <iostream.h>
► #include <iostream.h>

Question No: 7 ( Marks: 1 ) - Please choose one


The number 544.53 must be stored in data type.

► int
► short
► float
► char

Question No: 8 ( Marks: 1 ) - Please choose one


A template function can have different type of arguments.

► True
► False

Question No: 9 ( Marks: 1 ) - Please choose one


For which values of the integer _value will the following code becomes an infinite loop?

int
number=1;
while (true) {
cout << number;
if (number == 3) break;
number += integer_value;
}

► any number other than 1 or 2


► only 0
► only
1
► only
2

Question No: 10 ( Marks: 1 ) - Please choose one


Template class cannot have static variables.
16
► Tru
e
► False

17
Question No: 11 ( Marks: 1 ) - Please choose one
Which of the following is used with bit manipulation?

► Signed integer
► Un-signed integer
► Signed double
► Un-signed double

Question No: 12 ( Marks: 1 ) - Please choose one


Structure is a collection of under a single name.

► Only Functions
► Only Variables
► Both Functions and Variables
► None of the given options

Question No: 13 ( Marks: 1 ) - Please choose one


Which of the following is the correct C++ syntax to allocate space dynamically for an array of 10 int?

► new int(10)
;
► new int[10] ;
► int new(10)
;
► int
new[10];

Question No: 14 ( Marks: 1 ) - Please choose one


Unary operator implemented as member function takes arguments whereas non-member
function takes arguments.

► One,
zero
► Zero, one
► One,
two
► Two,
one

Question No: 15 ( Marks: 1 ) - Please choose one


The first parameter of overloaded stream insertion operator is where second parameter is

► input stream, object of class


► object of class, output stream
► output stream, object of class
► object of class, input stream

18
Question No: 16 ( Marks: 1 ) - Please choose one
We can also do conditional compilation with preprocessor directives.

► True
► False

19
Question No: 17 ( Marks: 1 ) - Please choose one
If a symbolic constant has been defined, it will be an error to define it again.

► True
► False

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


Classes defined inside other classes are called classes

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

Question No: 20 ( 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 .

► cannot be replaced
► None of the given options
► Remain constant.
► can be changed by some operation

Question No: 21 ( Marks: 1 ) - Please choose one


Assignment operator is-----------------------associative.

► right
► left
► binary
► unary
http://msdn.microsoft.com/en-us/library/ms173145.aspx

Question No: 22 ( Marks: 1 ) - Please choose one


If text is a pointer of class String then what is meant by the following statement?
text = new String [5];

► Creates an array of 5 string objects statically


► creates an array of 5 string objects dynamically
20
► Creates an array of pointers to string
► Creates a string Object

Question No: 23 ( Marks: 1 ) - Please choose one


The return type of the operator function for << operator is .

► class for which we overload operator


► reference of ostream class (ostream&)
► reference of istream class (istream&)
► void

Question No: 24 ( Marks: 1 ) - Please choose one


The code is written to the program.

► implement
► design
► analysis
► none of the given options.

Question No: 25 ( Marks: 1 ) - Please choose one


Memory allocated at run time is a system resource and it is the responsibility of to de-allocate
the memory.
► System
► Programmer
► User of program
► None of given options

Question No: 26 ( Marks: 1 ) - Please choose one


Templates are not type safe.

► True
► False

FINALTERM EXAMINATION
Spring 2010
CS201- Introduction to Programming

Question No: 1 ( Marks: 1 ) - Please choose one


*.doc is by type.
.
► Sequential File
► Random Access File
► Data File
► Record File

Question No: 2 ( Marks: 1 ) - Please choose one


Which of the following is NOT a preprocessor directive?

► #error
21
► #define
► #line
► #ndefine

Question No: 3 ( Marks: 1 ) - Please choose one


The return type of operator function must always be void.

► True
► False

Question No: 4 ( Marks: 1 ) - Please choose one


What does (*this) represents?

► The current function of the class


► The current pointer of the class
► The current object of the class
► A value of the data member

Question No: 5 ( Marks: 1 ) - Please choose one


The statement cin.get (); is used to,

► Read a string from keyboard


► Read a character from keyboard
► Read a string from file
► Read a character from file

Question No: 6 ( Marks: 1 ) - Please choose one


When we do dynamic memory allocation in the constructor of a class, then it is necessary to
provide a destructor.

► True
► False

Question No: 7 ( Marks: 1 ) - Please choose one


Overloaded new operator function takes parameter of type size_t and returns

► void (nothing)
► void pointer
► object pointer
► int pointer

Question No: 8 ( Marks: 1 ) - Please choose one


The second parameter of operator functions for << and >> are objects of the class for which we
are overloading these operators.

► True
► False

Question No: 9 ( Marks: 1 ) - Please choose one


22
C++ is a case-sensitive language

► True
► False

Question No: 10 ( Marks: 1 ) - Please choose one


To include code from the library in the program, such as iostream, a directive would be called up using
this command.

► #include “iostream.h”
► include <iostream.h>
► include <iostream.h>
► #include <iostream.h>

Question No: 11 ( Marks: 1 ) - Please choose one


A template function must have only generic data types.

► True
► False

Question No: 12 ( Marks: 1 ) - Please choose one


Template class can not have static variables.

► Tru
e
► False

Question No: 13 ( Marks: 1 ) - Please choose one


What will be the correct syntax to assign an array named arr of 5 elements to a pointer ptr?

► *ptr = arr ;
► ptr = arr ;
► *ptr = arr[5] ;
► ptr = arr[5] ;

Question No: 14 ( Marks: 1 ) - Please choose one


What will be the correct syntax to access the value of fourth element of an array using pointer ptr?

► ptr[3]
► (ptr+3)
► *(ptr+3)
► Both 1and 3

Question No: 15 ( Marks: 1 ) - Please choose one


If most significant bit of un-signed number is 1 then it represents a positive number.

► True
► False

23
Question No: 16 ( Marks: 1 ) - Please choose one

24
If there is a symbol (& sign) used with the variable name followed by data type then it refers to
and if & is being used with variable name
then it refers to .

► Address of variable, reference variable


► Reference variable, value of variable
► Reference variable, address of variable
► Address of variable, value of variable

Question No: 17 ( Marks: 1 ) - Please choose one


We can also do conditional compilation with preprocessor directives.

► True
► False

Question No: 18 ( Marks: 1 ) - Please choose one


The default value of a parameter can be provided inside the

► function prototype
► function definition
► both function prototype or function definition
► none of the given options.

Question No: 19 ( Marks: 1 ) - Please choose one


Classes defined inside other classes are called classes

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

Question No: 20 ( Marks: 1 ) - Please choose one


What purpose do classes serve?

► Data encapsulation
► Providing a convenient way of modeling real-world objects
► Simplifying code reuse
► All of the given options

Question No: 21 ( Marks: 1 ) - Please choose one


Every class contains .

► Constructor
► Destructor
► Both a constructor and a destructor (Lecture 27)
► None of the given options

Question No: 22 ( Marks: 1 ) - Please choose one


25
new operator is used to allocate memory from the free store during

26
► Compile Time
► Run Time
► Link Time
► None of the given options

Question No: 23 ( Marks: 1 ) - Please choose one


When an object of a class is defined inside another class then,

► Destructor of enclosing class will be called first


► Destructor of inner object will be called first
► Constructor and Destructor will be called simultaneously
► None of the given options

Question No: 24 ( Marks: 1 ) - Please choose one


It is possible to define a class within another class.

► True
► False

Question No: 25 ( Marks: 1 ) - Please choose one


New and Delete are also used with and data types as well.

► Class, Objects
► Structures, Pointers
► Both Class and structures
► None of above

Question No: 26 ( Marks: 1 ) - Please choose one


With New keyword, data types and class members are initialized with meaningful values instead
of garbage.

► True
► False

FINALTERM EXAMINATION
Spring 2010
CS201- Introduction to Programming

Question No: 1 ( Marks: 1 ) - Please choose one


If it is required to copy an array to another array then,

► Both arrays must be of the same size and data type


► Both arrays may be of different size
► Both arrays may be of different data type
► Both arrays may be of different size and type

27
Question No: 2 ( Marks: 1 ) - Please choose one
Dealing with structures and functions passing by reference is the most economical method

► True
► False
http://mathbits.com/MathBits/CompSci/Structures/Functions
.htm

Question No: 3 ( Marks: 1 ) - Please choose one


eof( ), bad( ), good( ), clear( ) all are manipulators.

► True
► False

Question No: 4 ( Marks: 1 ) - Please choose one


Overloaded new operator function takes parameter of type size_t and returns

► void (nothing)
► void pointer
► object pointer
► int pointer

Question No: 5 ( Marks: 1 ) - Please choose one


When new operator is overloaded at global level then corresponding built-in new operator will
not be visible to whole of the program.

► True
► False

Question No: 6 ( Marks: 1 ) - Please choose one


If there is more than one statement in the block of a for loop, which of the following must be placed
at the beginning and the ending of the loop block?

► parentheses ( )
► braces { }
► brackets [ ]
► arrows < >

Question No: 7 ( Marks: 1 ) - Please choose one


The return type of a function that do not return any value must be

► float
► int
► void
► double

Question No: 8 ( Marks: 1 ) - Please choose one


UNIX has been developed in language.
28
► JAVA
►B
►C
► FORTRAN

Question No: 9 ( Marks: 1 ) - Please choose one


Like member functions, can also access the private data members of a class.

► Non-member functions
► Friend functions
► Any function outside class
► None of the given options

Question No: 10 ( Marks: 1 ) - Please choose one


Which of the following statement is best regarding declaration of friend function?

► Friend function must be declared after public keyword.


► Friend function must be declared after private keyword.
► Friend function must be declared at the top within class definition.
► It can be declared anywhere in class as these are not affected by the public and private
keywords.

Question No: 11 ( Marks: 1 ) - Please choose one


The operator function overloaded for an Assignment operator (=) must be

► Non-member function of class


► Member function of class
► Friend function of class
► None of the given options

Question No: 12 ( Marks: 1 ) - Please choose one


The endl and flush are

► Functions
► Operators
► Manipulators
► Objects

Question No: 13 ( Marks: 1 ) - Please choose one


If a symbolic constant has been defined, it will be an error to define it again.

► True
► False

Question No: 14 ( Marks: 1 ) - Please choose one


The operator used for casting, in C, is standard operator.
29
► none of the given options.
► cast
► cost
► const

Question No: 15 ( Marks: 1 ) - Please choose one


Constructors can not be overloaded like ordinary functions.

► True
► False

Question No: 16 ( Marks: 1 ) - Please choose one

Which of the following function call is correct for the function prototype?
defaultParameters ( int a, int b = 7, char z = ‘*’ );

► defaultParameters (5);
► defaultParameters (5, ‘8’);
► defaultParameters (6, ‘#’);
► defaultParameters (0, 0, ‘*’, 0);

Question No: 17 ( Marks: 1 ) - Please choose one


When an operator function is defined as member function for a binary Plus (+) operator then the
number of argument it take is/are.

► Zero
► One
► Two
► N arguments

Question No: 18 ( Marks: 1 ) - Please choose one


We can not define a variable of user-defined data type in the class.

► True
► False

Question No: 19 ( Marks: 1 ) - Please choose one


When an object of a class is defined inside an other class then,

► Constructor of enclosing class will be called first


► Constructor of inner object will be called first
► Constructor and Destructor will be called simultaneously
► None of the given options

30
Question No: 20 ( Marks: 1 ) - Please choose one
The appropriate data type to store the number of rows and colums of the matrix is .

► float
► int
► char
► none of the given options.

Question No: 21 ( Marks: 1 ) - Please choose one


Class is a user defined .

► data type
► memory referee
► value
► none of the given options.

Question No: 22 ( Marks: 1 ) - Please choose one


A pointer variable can be,

► Decremented
► Incremented
► Multiplied
► Both Iecremented and Decremented

Question No: 23 ( Marks: 1 ) - Please choose one

NULL value has been defined in and header files.

► strings.h and iostream.h


► ctype.h and conio.c
► conio.c and conio.h
► stdlib.h and stddef.h

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


"setprecision" manipulator will set
31
► The number of digits after the decimal point
► The number of digits before the decimal point
► The number of digits in a number
► None of the given options

Question No: 26 ( Marks: 1 ) - Please choose one


Which of the following option will be true, if we overload "-=" operator?

► only - operator needs to be overloaded


► Minus (-) and = operators need to be overloaded
► the -= operator need to be overloaded explicitly
► the - and = operators need to be overloaded implicitly

Fall 2009
CS201- Introduction to Programming

Question No: 1 ( Marks: 1 ) - Please choose one


In C/C++ if we define an array of size eight (8) i.e. int Arr [8]; then the last element of this array will be
stored at,

► Arr[0]
► Arr[8]
► Arr[7]
► Arr[-1]

Question No: 2 ( Marks: 1 ) - Please choose one


When an array is passed to a function then default way of passing this array is,

► By data
► By reference
► By value
► By data type

Question No: 3 ( Marks: 1 ) - Please choose one


Array is a data structure which store

► Memory addresses
► Variables
► Data Type
► Data

Question No: 4 ( Marks: 1 ) - Please choose one


We can also create an array of user define data type.

► True
► False
32
Question No: 5 ( Marks: 1 ) - Please choose one
When we define an array of objects then,

► Destructor will call once for whole array


► Destructor will call for each object of the array
► Destructor will never call
► Depends on the size of array

Question No: 6 ( Marks: 1 ) - Please choose one


What is the sequence of event(s) when allocating memory using new operator?

► Only block of memory is allocated for objects


► Only constructor is called for objects
► Memory is allocated first before calling constructor
► Constructor is called first before allocating memory

Question No: 7 (Marks: 1) - Please choose one


We can delete an array of objects without specifying [] brackets if a class is not doing dynamic
memory allocation internally.

► True
► False

Question No: 8 ( Marks: 1 ) - Please choose one


The second parameter of operator functions for << and >> are objects of the
class For which we are overloading these operators.

► True
► False

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


Default mechanism of function calling in case of array is and in case
of variable is .

► Call by value, call by reference


► Call by referene, call by reference
► Call by reference, call by value
► Call by value, call by value

Question No: 11 ( Marks: 1 ) - Please choose one


What does STL stand for?
► Source template library
33
► Standard template library
► Stream template library
► Standard temporary library

Question No: 12 ( Marks: 1 ) - Please choose one


Skill(s) that is/are needed by programmer’s .

► Paying attention to detail


► Think about the reusability
► Think about user interface
► All of the given options

Question No: 13 ( Marks: 1 ) - Please choose one


For which array, the size of the array should be one more than the
number of elements in an array?

► int
► double
► float
► char

Question No: 14 ( Marks: 1 ) - Please choose one


new and delete are whereas malloc and free are .

► Functions, operators
► Classes, operators
► Operators, functions
► Operators, classes

Question No: 15 ( Marks: 1 ) - Please choose one


Friend functions are of a class.

► Member functions
► Public member functions
► Private member functions
► Non-member functions

Question No: 16 ( Marks: 1 ) - Please choose one


The prototype of friend functions must be written the class and
its definition must be written

► inside, inside the class


► inside, outside the class
► outside, inside the class
► outside, outside the class

Question No: 17 ( Marks: 1 ) - Please choose one


If overloaded plus operator is implemented as non-member function then
which of the following statement will be true for the statement given
below?
obj3 = obj1 + obj2 ;
34
► obj2 will be passed as an argument to + operator whereas obj2 will

35
drive the + operator
► obj1 will drive the + operator whereas obj2 will be passed as an
argument to + operator
► Both objects (obj1, obj2) will be passed as arguments to the + operator (not sure)
► Any of the objects (obj1, obj2) can drive the + operator

Question No: 18 ( Marks: 1 ) - Please choose one


Which one of the following is the declaration of overloaded pre-increment operator implemented as
member function?

► Class-name operator +() ;


► Class-name operator +(int) ;
► Class-name operator ++() ;
► Class-name operator ++(int) ;

Question No: 19 ( Marks: 1 ) - Please choose one


For cin, the source is normally a and destination can be .

► File, native data type


► Disk, user-define type
► Keyboard, variable
For cin, the source is normally keyboard and the destination can be an ordinary variable

► File, user-define type

Question No: 20 ( Marks: 1 ) - Please choose one


We can also do conditional compilation with preprocessor directives.

► True
► False

Question No: 21 ( Marks: 1 ) - Please choose one


The programs, in which we allocate static memory, run essentially on _

► Heap
► System Cache
► None of the given options
► Stack
The programs, in which we allocate static memory, run essentially on stack.

Question No: 22 ( Marks: 1 ) - Please choose one


The default value of a parameter can be provided inside the

► function prototype
► function definition
► both function prototype or function definition
► none of the given options.

The default value of a parameter is provided inside the function prototype or function definition.

Question No: 23 ( Marks: 1 ) - Please choose one


36
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: 24 ( Marks: 1 ) - Please choose one


When an operator function is defined as member function for a binary Plus (+) operator then the
number of argument it take is/are.

► Zero
► One
► Two
► N arguments

Question No: 25 ( Marks: 1 ) - Please choose one


With user-defined data type variables (Objects), self assignment can produce
.

► Syntax error
► Logical error
► Link error
► Non of the given options

Question No: 26 ( Marks: 1 ) - Please choose one


Assignment operator is used to initialize a newly declared object from
existing object.

► True
► False

Question No: 27 ( Marks: 1 ) - Please choose one


When an object of a class is defined inside an other class then,

► Constructor of enclosing class will be called first


► Constructor of inner object will be called first
► Constructor and Destructor will be called simultaneously
► None of the given options

Question No: 28 ( Marks: 1 ) - Please choose one


In the member initializer list, the data members are initialized,

► From left to right


► From right to left
► In the order in which they are defined within class
► None of the given options

Question No: 29 ( Marks: 1 ) - Please choose one


new operator allocates memory from free store and return .

37
► A pointer
► A reference
► An integer
► A float

Question No: 30 ( Marks: 1 ) - Please choose one


"new" and "delete" keywords are in C++ language.

► Built-in- Function
► Operators
► Memory Allocation Function
► None of the given options

Spring 2010
CS201- Introduction to Programming

Question No: 1 ( Marks: 1 ) - Please choose one


&& is operator.

► An arithmetic
► Logical
► Relational
► Unary

Question No: 2 ( Marks: 1 ) - Please choose one


Which of the following function(s) is/are included in ctype.h header file?

► isdigit(int c)
► isxdigit(int c )
► tolower(int c)
► All of the above
Question No: 3 ( Marks: 1 ) - Please choose one
Disks are devices having access time of milliseconds.

► Electro-physical, 6
► Electro-Mechanical, 4
► Electro-physical, 5
► Electro-Mechanical, 7
http://www.tns.com/taocs_dp.asp

Question No: 4 ( Marks: 1 ) - Please choose one


All preprocessor directives are started with the symbol .

►*

38
► ++
►@
►#

Question No: 5 ( Marks: 1 ) - Please choose one


When we use manipulators in our program then which header file
should be included?

► iostream.h
► stdlib.h
► stdio.h
► iomanip.h
Question No: 6 ( Marks: 1 ) - Please choose one
setprecision is a parameter less manipulator.

► True
► False
Question No: 7 ( Marks: 1 ) - Please choose one
Which of the following is NOT a preprocessor directive?

► #error
► #define
► #line
► #ndefine

Question No: 8 ( Marks: 1 ) - Please choose one


We can do arithmetic with references like pointers.

► True
► False

Question No: 9 ( Marks: 1 ) - Please choose one


What does (*this) represents?

► The current function of the class


► The current pointer of the class
► The current object of the class
► A value of the data member

Question No: 10 ( Marks: 1 ) - Please choose one


Friend function of a class is .

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

Question No: 11 ( Marks: 1 ) - Please choose one


A function can declare itself a friend of a class.

39
► True
► False

Question No: 12 ( Marks: 1 ) - Please choose one


Overloaded delete operator function takes the same parameter as an
argument returned by new operator function.

► True
► False

Question No: 13 ( Marks: 1 ) - Please choose one


The second parameter of operator functions for << and >> are objects of the
class for which we are overloading these operators.

► True
► False
The second parameter to operator << is an object of the class that we are overloading the operator for.
Similar is the case for operator >>

Question No: 14 ( Marks: 1 ) - Please choose one


A template function must have at least--------generic data type

► Zero
► One
► Two
► Three

Question No: 15 ( Marks: 1 ) - Please choose one


A template function must have only generic data types.

► True
► False
Question No: 16 ( Marks: 1 ) - Please choose one
We can not make a member function of a class as template function.

► True
► False
Question No: 17 ( Marks: 1 ) - Please choose one
Which character is inserted at the end of string to indicate the end of string?

► new line
► tab
► null
► carriage return

Question No: 18 ( Marks: 1 ) - Please choose one


is used for .

40
► calculation
► reading
► assigning value to variables
► None of the given options.

Question No: 19 ( Marks: 1 ) - Please choose one vuzs


The object may be used both for file input and file output

► fstream,
► ifstream,
► ofstream,
► none of the given options.

Question No: 20 ( Marks: 1 ) - Please choose one


Which of the following function calling mechanism is true for the function prototype given below?

float func(float &);


► Call by value
► Call by reference using pointer
► Call by reference using reference variable
► None of the given options

Question No: 21 ( Marks: 1 ) - Please choose one


The programs, in which we allocate static memory, run essentially on _

► Heap
► System Cache
► None of the given options
► Stack

Question No: 22 ( Marks: 1 ) - Please choose one


Overloaded delete operator function takes parameter of void pointer and returns
.

► void
► void pointer
► pointer to an object
► pointer of type int

Question No: 23 ( Marks: 1 ) - Please choose one


What should be the return type of the constructor?

► void pointer
► int
► same as object type
► constructors do not return any thing

Question No: 24 ( Marks: 1 ) - Please choose one


It is a way of reusing the code when we contain objects of our already written classes into a new class,

► True
41
► False

Question No: 25 ( Marks: 1 ) - Please choose one vuzs


Templates are not type safe.

► true
► false
Question No: 26 ( Marks: 1 ) - Please choose one
The functions used for dynamic memory allocation return pointer of type

► int
► float
► void
► double

FINALTERM EXAMINATION
Fall 2008
CS201- Introduction to Programming

Question No: 1 ( Marks: 1 ) - Please choose one


There are mainly-------------------types of software

► Two Three
► Four
► Five

Question No: 2 ( Marks: 1 ) - Please choose one


seekg() and write() are functionally .

► Different
► Identical
► Two names of same function
► None of the above

Question No: 3 ( Marks: 1 ) - Please choose one

When a pointer is incremented, it actually jumps the number of memory addresses

► According to data type (


► 1 byte exactly
► 1 bit exactly
► A pointer variable can not be incremented

Question No: 4 ( Marks: 1 ) - Please choose one


setw is a parameterized manipulator.

42
► True
► False

Question No: 5 ( Marks: 1 ) - Please choose one


eof( ), bad( ), good( ), clear( ) all are manipulators.

► True
► False

Question No: 6 ( Marks: 1 ) - Please choose one


In functions that return reference, use variables.

► Local
► Global
► Global or static
► None of the given option

Question No: 7 ( Marks: 1 ) - Please choose one


The declarator of Plus (+) member operator function is

► Class-Name operator + (Class-Name rhs)


► operator Class-Name + ( )
► operator Class-Name + ( rhs)
► Class-Name operator + ( )

Question No: 8 ( Marks: 1 ) - Please choose one


The compiler does not provide a copy constructor if we do not provide it.

► True
► False

Question No: 9 ( Marks: 1 ) - Please choose one


What is the functionality of the following syntax to delete an array of 5 objects named arr allocated
using new operator?
delete arr ;

► Deletes all the objects of array


► Deletes one object of array Do not delete any object
► Results into syntax error
This statement will call the destructor only for the object pointed by the arr and deallocate the space
allocated to this object

Question No: 10 ( Marks: 1 ) - Please choose one


What is the sequence of event(s) when allocating memory using new operator?

43
► Only block of memory is allocated for objects
► Only constructor is called for objects
► Memory is allocated first before calling constructor
► Constructor is called first before allocating memory
Question No: 11 ( Marks: 1 ) - Please choose one
What is the sequence of event(s) when deallocating memory using delete operator?

► Only block of memory is deallocated for objects


► Only destructor is called for objects
► Memory is deallocated first before calling destructor
► Destructor is called first before deallocating memory

Question No: 12 ( Marks: 1 ) - Please choose one


new and delete operators cannot be overloaded as member functions.

► True
► False

Question No: 13 ( Marks: 1 ) - Please choose one


The operator function of << and >> operators are always the member function of a class.

► True
► False

Question No: 14 ( Marks: 1 ) - Please choose one


A template function must have at least--------generic data type

► Zero
► One
► Two
► Three

Question No: 15 ( Marks: 1 ) - Please choose one


If we do not mention any return_value_type with a function, it will return an value.

► int
► void
► double
► float

Question No: 16 ( Marks: 1 ) - Please choose one


Suppose a program contains an array declared as int arr[100]; what will be the size of array?

►0
► 99
► 100
► 101

44
Question No: 17 ( Marks: 1 ) - Please choose one
The name of an array represents address of first location of array element.

► True
► Fals
e
The name of the array is a constant pointer which contains the memory is the address of first
element of the array

Question No: 18 ( Marks: 1 ) - Please choose one


Reusing the variables in program helps to save the memory

► True
► Fals
e

Question No: 19 ( Marks: 1 ) - Please choose one


Which of the following option is true about new operator to dynamically allocate memory to an object?

► The new operator determines the size of an object


► Allocates memory to object and returns pointer of valid type
► Creates an object and calls the constructor to initialize the object
► All of the given options

Question No: 20 ( Marks: 1 ) - Please choose one


New and delete are _ whereas malloc and free are .

► Functions, operators
► Classes, operators
► Operators, functions
► Operators, classes

Question No: 21 ( Marks: 1 ) - Please choose one


Like member functions, can also access the private data members of a class.

► Non-member functions
► Friend functions
► Any function outside class
► None of the given options

Question No: 22 ( Marks: 1 ) - Please choose one


Which of the following statement is best regarding declaration of friend function?

► Friend function must be declared after public keyword.


► Friend function must be declared after private keyword.
► Friend function must be declared at the top within class definition.

45
► It can be declared anywhere in class as these are not affected by the public and private
keywords.

46
Question No: 23 ( Marks: 1 ) - Please choose one
The operator function overloaded for an Assignment operator (=) must be

► Non-member function of class


► Member function of class
► Friend function of class
► None of the given options

Question No: 24 ( Marks: 1 ) - Please choose one


For non-member operator function, object on left side of the operator may be

► Object of operator class


► Object of different class
► Built-in data type
► All of the given options

Question No: 25 ( Marks: 1 ) - Please choose one


The operator function will be implemented as , if obj1 drive the - operator whereas obj2 is
passed as arguments to - operator in the statement given below.
obj3 = obj1 - obj2;

► Member function Non-member function


► Friend function
► None of the given options

Question No: 26 ( Marks: 1 ) - Please choose one


Which one of the following is the declaration of overloaded pre-increment operator implemented
as member function?

► Class-name operator +() ;


► Class-name operator +(int) ;
► Class-name operator ++() ;
► Class-name operator ++(int) ;

Question No: 27 ( Marks: 1 ) - Please choose one


The static data members of a class are initialized

► at file scope
► within class definition
► within member function
► within main function

Question No: 28 ( Marks: 1 ) - Please choose one


Class is a user defined .

► data type

47
► memory referee
► value
► none of the given options.

Question No: 29 ( Marks: 1 ) - Please choose one


We can also define a user-defines manipulators.

► True
► Fals
e
Parameterized manipulators require one or more arguments. setfill (near the bottom of the iomanip.h header file) is an
example of a parameterized manipulator. You can create your own parameterized manipulators and your own simple
manipulators.

Question No: 30 ( Marks: 1 ) - Please choose one


Automatic variable are created on .

► Heap
► Free store
► static storage
► stack

FINALTERM EXAMINATION
fall 2008
CS201- Introduction to Programming (Session - 2)

Question No: 1 ( Marks: 1 ) - Please choose one


If Num is an integer variable then Num++ means,

 Add 1 two times with Num


 Add 1 with Num
 Add 2 with Num
 Subtract 2 from Num

Question No: 2 ( Marks: 1 ) - Please choose one


If the return type of a function is void then it means that it will,

 Return any type of data


 Return some specific type of data
 Return no data
 Return just character data
Question No: 3 ( Marks: 1 ) - Please choose one
Which of the following is a valid class declaration?

 class A { int x; };
 class B { }
 public class A { }
 object A { int x; };

48
Question No: 4 ( Marks: 1 ) - Please choose one

49
When we use manipulators in our program then which header file should be included?

 iostream.h
 stdlib.h
 stdio.h
 iomanip.h

Question No: 5 ( Marks: 1 ) - Please choose one


We can also create an array of user define data type.

 True
 False

Question No: 6 ( Marks: 1 ) - Please choose one


The normal source of cin object is,

 File
 Disk
 Keyboard
 RAM

Question No: 7 ( Marks: 1 ) - Please choose one


A stream is an ordered sequence of bytes.

 True
 False

Question No: 8 ( Marks: 1 ) - Please choose one


What is the sequence of event(s) when allocating memory using new operator?

 Only block of memory is allocated for objects


 Only constructor is called for objects
 Memory is allocated first before calling constructor
 Constructor is called first before allocating memory

Question No: 9 ( Marks: 1 ) - Please choose one


We can delete an array of objects without specifying [] brackets if a class is not doing dynamic
memory allocation internally.

 True
 False
Question No: 10 ( Marks: 1 ) - Please choose one
The second parameter of operator functions for << and >> are objects of the
class for which we are overloading these operators.

 True
 False

Question No: 11 ( Marks: 1 ) - Please choose one


Which looping process checks the test condition at the end of the loop?

50
 for
 while
 do while
 no looping process checks the test condition at the end
http://mathbits.com/MathBits/CompSci/looping/MCLooping.
htm

Question No: 12 ( Marks: 1 ) - Please choose one


In a group of nested loops, which loop is executed the most number of times?

 the outermost loop


 the innermost loop
 all loops are executed the same number of times
 cannot be determined without knowing the size of the
loops
http://mathbits.com/mathbits/java/Looping/MCLooping.htm

Question No: 13 ( Marks: 1 ) - Please choose one


Template class can not have static variables.

 True
 False

Question No: 14 ( Marks: 1 ) - Please choose one


Consider the following statements to initialize a two-dimensional array.

 int arr[2][3] = {4, 8, 9, 2, 1, 6} ;


 int arr[3][2] = {4, 8, 9, 2, 1, 6} ;
 int arr[][2] = {{4,8},{9, 2},{1, 6}} ;

Which of the following option(s) are correct to initialize a two-dimensional array


with 3 rows and 2 columns?

 (ii) only
 (iii) only
 (ii) and (iii)
 and (iii)

Question No: 15 ( Marks: 1 ) - Please choose one


There is a pointer variable named ptr of type int then address of which type of variable the ptr will store in
it?

 variable of type char


 variable of type short
 variable of type int
 variable of type double

Question No: 16 ( Marks: 1 ) - Please choose one


Let suppose
Union intorDouble{
Int ival;
51
Double charvar;
};
main(){

52
intorDouble VAZ;
int size ;
size = sizeof(VAZ);
}
What will be the value of variable "size", if int occupies 4 bytes and double
occupies 8 bytes?

 2
 4
 8
 12

Question No: 17 ( Marks: 1 ) - Please choose one


new and delete are whereas malloc and free are .

 Functions, operators
 Classes, operators
 Operators, functions
 Operators, classes

Question No: 18 ( Marks: 1 ) - Please choose one


The member functions of a class occupy region in memory for object(s) of class.

 separate, each
 common, all
 different, each
 different, all

Question No: 19 ( Marks: 1 ) - Please choose one


Friend functions are of a class.

 Member functions
 Public member functions
 Private member functions
 Non-member functions

Question No: 20 ( Marks: 1 ) - Please choose one


Which of the following is true while overloading operators?

 Precedence of an operator can be changed


 The arity (number of operands) can be changed
 No new operators can be created
 Associativity of an operator can be changed

Question No: 21 ( Marks: 1 ) - Please choose one


Which of the following option will be true to overload the -= operator?

 only - operator needs to be overloaded (not sure)


 Minus (-) and = operators need to be overloaded
 the -= operator need to be overloaded explicitly
 the - and = operators need to be overloaded implicitly
53
Question No: 22 ( Marks: 1 ) - Please choose one
The input/output streams; cin and cout are

 Operators
 Functions
 Objects
 Structures

Question No: 23 ( Marks: 1 ) - Please choose one


dec, hex, oct are all

 Member functions
 Objects of input/output streams
 Parameterized manipulators
 Non-parameterized manipulators
Question No: 24 ( Marks: 1 ) - Please choose one
What will be the output of the following
statement? cout << setbase(16) << 52 ;

 74
 52
 34
 64

Question No: 25 ( Marks: 1 ) - Please choose one


The first parameter of overloaded stream insertion operator is where second parameter is

 input stream, object of class


 object of class, output stream
 output stream, object of class
 object of class, input stream

Question No: 26 ( Marks: 1 ) - Please choose one


We can also do conditional compilation with preprocessor directives.

 True
 False

Question No: 27 ( Marks: 1 ) - Please choose one


With user-defined data type variables (Objects), self assignment can produce .

 Syntax error
 Logical error
 Link error
 Non of the given options

Question No: 28 ( Marks: 1 ) - Please choose one


The return type of the operator function for >> operator is .

54
 class for which we overload this operator
 reference of ostream class (ostream&)
 reference of istream class (istream&)
 void

Question No: 29 ( Marks: 1 ) - Please choose one


When an object of a class is defined inside an other class then,

 Constructor of enclosing class will be called first


 Constructor of inner object will be called first
 Constructor and Destructor will be called simultaneously
 None of the given options

Question No: 30 ( Marks: 1 ) - Please choose one


Where we can include a header file in the program?

 any where
 in start
 at the end
 none of the given options.

55

You might also like