CS201 Final Term Solved Past Papers By Moaz:
Question No: 1 ( Marks: 1 ) - Please choose
one
All
A template function must have at least ---------- generic data type
►
Zero
►
One (Page 499)
►
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 ++() ; (Page 389)
►
Class-name operator ++(int) ;
Question No: 4 ( Marks: 1 ) - Please choose
one
Class
is a user defined___________.
► data type (Page 317)
►
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 (Page 267)
►
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
Question No: 9 ( Marks: 1 ) - Please choose
one
Computer
can understand only machine language code.
► True
► False
Question No: 10 ( Marks: 1 ) - Please choose
one
We
can not define a function as a friend of a Template class.
► True
► False (Page 151)
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
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 (Page 527)
►
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 (Page 283)
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 _____ .
► stack
► 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 (Page 440)
► None
of the given option
Question
No: 25 ( Marks: 1 ) - Please choose one
Templates
are not type safe.
►
true
► false (Page 518)
No comments:
Post a Comment