CS201 – Introduction To Programming Mcqs Pdf with Answers Part 03


101      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] ;


103      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


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

► True

► False


105      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


106      We can also do conditional compilation with preprocessor directives.

True

► False


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


108      Classes defined inside other classes are called ________ classes

► looped

► nested

► overloaded

► none of the given options.


109      What purpose do classes serve?

► Data encapsulation

► Providing a convenient way of modeling real-world objects

► Simplifying code reuse

► All of the given options


110      Every class contains _______________.

► Constructor

► Destructor

► Both a constructor and a destructor 

► None of the given options


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

► Compile Time

► Run Time

► Link Time

► None of the given options


113      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


114      It is possible to define a class within another class.

► True

► False


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

Class, Objects

► Structures, Pointers

► Both Class and structures

► None of above


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

True

► False


118      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


119      Dealing with structures and functions passing by reference is the most economical method

► True

► False


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

► True

► False


121      Overloaded new operator function takes parameter of type size_t and returns

► void (nothing)

► void pointer

► object pointer

► int pointer


122      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


123      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 < >


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

► float

► int

void

► double


125      UNIX has been developed in ________ language.

► JAVA

► B

C

► FORTRAN


126      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


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


128      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


129      The endl and flush are _______

► Functions

► Operators

► Manipulators

► Objects


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

True

► False


131      The operator used for casting, in C, is standard ________ operator.

► none of the given options.

► cast

► cost

► const


132      Constructors can not be overloaded like ordinary functions.

► True

► False


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


134      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


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

► True

► False


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

Constructor of enclosing class will be called first (Page 464)

► Constructor of inner object will be called first

► Constructor and Destructor will be called simultaneously

► None of the given options


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


138      Class is a user defined___________.

data type

► memory referee

► value

► none of the given options.


137      A pointer variable can be,

► Decremented

► Incremented

► Multiplied

► Both Incremental and Decremented


138      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


139      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


140      “setprecision” manipulator will set 

► 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


141      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


142      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]


143      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


144      Array is a data structure which store

► Memory addresses

► Variables

► Data Type

► Data


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

► True

► False 


146      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


147      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


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

► True

► False


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

► True

► False


150      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 ; (sure)

► int x, x = 10;

► x = 10 ;