CS201 Solved MidTerm201 4
CS201 Solved MidTerm201 4
BS IT (3rd Semester)
[email protected]
Question No: 1 If we write a statement like s2 = s1; ___ will be the calling object
and ____ will be passed to the = operator as an argument.
s1, s1
s1, s2
s2, s1
s2, s2
Question No: 2 If we write a statement like s2 = s1; s2 will be the calling object
and s1 will be passed to the = operator as an argument.
cout << setfill(0) << setw(7) << 128 ;
0000128
0128128
1280000
0012800
Question No: 3 The stream insertion and extraction operators are not already
overloaded for _______
Built-in data types
User-defined data types
Both built-in and user-defined types
None of the given options
Question No: 4 Constructors can not be overloaded like ordinary functions.
True
False
Question No: 5 Overloaded new operator function takes parameter of type
size_t and returns
void (nothing)
void pointer
object pointer
int pointer
Question No: 6 Which of the following is the correct way to declare a variable x
of integer type?
x int ;
integer x ;
int x;
x integer
Question No: 7 Reserve words cannot be used as a variable name.
True
False
Question No: 8 A template function must have at least ---------- generic data
type
Zero
One
Two
Three
Question No: 9 Template functions can also be overloaded
True
False
Question No: 10 We can not make a member function of a class as template
function.
True
False not sure
Question No: 11 When break statement is encountered in switch statement, it
Stops the entire program
Stops the execution of current statement
Exits from switch statement
None of the given options
Question No: 12 We can also define a variable of user define data type (object)
as static.
True
False
Question No: 13 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: 14 Let suppose
int a, b, c, d, e;
a = b = c = d = e = 42;
This can be interpreted by the complier as:
a = (b = (c = (d = (e = 42))));
(a = b = (c = (d = (e = 42))));
a = b = (c = (d = (e = 42)));
(a = b) = (c = d) = (e = 42);
Question No: 15 What will be the range of numbers generated by function rand
() % 9?
0 to 9
1 to 9
0 to 8
1 to 8
Question No: 16 When 6 divides any number, the remainder will always be less
than 6. Then result will be between therefore we will add 1. 1 + rand ( ) % 6;
Which of the following is the correct function call having array named student of
10 elements as a parameter.
addRecord(student[]) ;
addRecord(student) ;
addRecord(student[10]) ;
addRecord(*student) ;
Question No: 17 Declaring structures does not mean that memory is allocated.
True
False
Question No: 18 Identifier is a name that can be given to variables, labels and
functions.
True
False
Question No: 19 If a class A declares itself a friend of class B and a class B
declares itself a friend of class C then
Class A is also a friend of class C.
Class B is also a friend of class A.
Class A is also a friend of class C if A declares C as its friend.
Class A is also a friend of class C if C declares A as its friend.
Question No: 20 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: 21 A pointer is a special type of variable that contain
___________
Memory Address
Data values
Both Values and Memory
None of given of options
Question No: 22 When memory for a program is allocated at run time then it is
called ___
static memory allocation
dynamic memory allocation
stack memory allocation
virtual memory allocation
Question No: 23 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: 24 Which of the following function cannot be overloaded?
Member functions
Utility functions
Constructor
Destructor
Question No: 25 The following prototype of unary operator function indicates
that it is __
Member functions of post increment operator
Member functions of pre increment operator
Non-member functions of post increment operator
Non-member functions of pre increment operator
Question No: 26 Static variable which is defined in a function is initialized
__________.
Only once during its life time
Every time the function call
Compile time of the program
None of the above
Question No: 27 In the member initialize 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: 28 If we do not indent the code properly it will
__________________
Be a syntax error
Be a logical error
Not be an error at all
None of the given options
Question No: 29 Truth tables are used for analyzing ___________.
logical expressions
arithmetic expressions
both logical and arithmetic expressions
none of the given options.
Question No: 30 Static memory allocation is also known as ____________
Dynamic allocation
Compile time allocation
Run time allocation
None of the given options
Question No: 1 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: 2 We can also create an array of user define data type
True
False
Question No: 3 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: 4 We can delete an array of objects without specifying []
brackets if a class is not doing dynamic memory allocation internally
True
False
Question No: 5 The declarator of Plus (+) member operator function is
Friend functions
Any function outside class
None of the given options
Question No: 15 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 ;
obj2 will be passed as an argument to + operator
whereas obj2 will drive the + operator
obj1 will drive the + operator whereas obj2 will be passed as an
argument to + operator
True
False
Question No: 27 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 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 "new" and "delete" keywords are
in C++ language
Built-in- Function
Operators
Memory Allocation Function
None of the given options
Question No: 1 There are mainly -------------------- types of software
Two
Three
Four
Five
Question No: 2 When x = 7; then the expression x%= 2; will calculate the value
of x as,
1
3
7
2
Question No: 3 A pointer variable can be,
Decremented only
Incremented only
Multiplied only
Both 1 and 2
Question No: 4 setprecision is a parameter less manipulator.
True
False
Question No: 5 We can change a Unary operator to Binary operator through
operator overloading.
False
True
Question No: 6 delete operator is used to return memory to free store which is
allocated by the new operator
True
False
Question No: 7 When we do dynamic memory allocation in the constructor of a
class, then it is necessary to provide a destructor
True
False
Question No: 8 What is the functionality of the following statement?
String str[5] = {String(Programming), String(CS201)};
Default constructor will call for all objects of array
Parameterized constructor will call for all objects of array
Parameterized constructor will call for first 2 objects and default
constructor for
remaining objects
Default constructor will call for first 3 objects and Parameterized
constructor for
remaining objects
Question No: 9 What is the sequence of event(s) when allocating memory
using new operator?