CS201 – Introduction To Programming Mcqs Pdf with Answers Part 05

Print/Downlaod pdf

201      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


202      setw is a parameterized manipulator.

► True

► False


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

► True

► False


204      In functions that return reference, use __________variables.

► Local

► Global

► Global or static

► None of the given option


205      The declarator of Plus (+) member operator function is

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

► operator Class-Name + ( )

► operator Class-Name + ( rhs)

► Class-Name operator + ( )


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

► True

► False


207      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


208      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  11   What is the sequence of event(s)


209            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 


210      new and delete operators cannot be overloaded as member functions.

► True

► False


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

► True

► False


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

► Zero

► One

► Two

► Three


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

► int

► void

► double

► float


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

► 0

► 99

► 100

► 101


215      The name of an array represents address of first location of array element.

► True

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


 216     Reusing the variables in program helps to save the memory

► True

► False


218        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


219      New and delete are _____ whereas malloc and free are _____.

► Functions, operators

► Classes, operators

► Operators, functions

► Operators, classes


220      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


221      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.


222      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


223      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


224      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


 225     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) ;


226      The static data members of a class are initialized _______

► at file scope

► within class definition

► within member function

► within main function


227      Class is a user defined___________.

► data type

► memory referee

► value

► none of the given options.


228      We can also define a user-defines manipulators.

► True

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


229      Automatic variable are created on ________.

► Heap

► Free store

► static storage

► stack


230      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


231      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 


232      Which of the following is a valid class declaration?

➢ class A { int x; };

➢ class B { }

➢ public class A { }

➢ object A { int x; };


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

➢ iostream.h

➢ stdlib.h

➢ stdio.h

➢ iomanip.h


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

➢ True

➢ False


235      The normal source of cin object is,

➢ File

➢ Disk

➢ Keyboard

➢ RAM


236      A stream is an ordered sequence of bytes.

➢ True

➢ False


237      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


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

➢ True

➢ False  10  


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

➢ True

➢ False


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

➢ for

➢ while

➢ do while

➢ no looping process checks the test condition at the end


241      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


242      Template class can not have static variables.

➢ True

➢ False


243      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}} ;


244      =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)


245      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


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

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


247      new and delete are _____ whereas malloc and free are _____.

➢ Functions, operators

➢ Classes, operators

➢ Operators, functions

➢ Operators, classes


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

➢ separate, each

➢ common, all

➢ different, each

➢ different, all


249      Friend functions are _____ of a class.

➢ Member functions

➢ Public member functions

➢ Private member functions

➢ Non-member functions 


250      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


251      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


252      The input/output streams; cin and cout are ____

➢ Operators

➢ Functions

➢ Objects

➢ Structures


253        dec, hex, oct are all __________

➢ Member functions

➢ Objects of input/output streams

➢ Parameterized manipulators

➢ Non-parameterized manipulators


254      What will be the output of the following statement? cout << setbase(16) << 52 ;

➢ 74

➢ 52

➢ 34

➢ 64


255      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


256      We can also do conditional compilation with preprocessor directives.

➢ True 

➢ False


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

➢ Syntax error

➢ Logical error

➢ Link error

➢ Non of the given options


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

➢ class for which we overload this operator

➢ reference of ostream class (ostream&)

➢ reference of istream class (istream&)

➢ void


 259     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


 260     Where we can include a header file in the program?

➢ any where 

➢ in start

➢ at the end

➢ none of the given options.