212A - OBJECT ORIENTED PROGRAMMING WITH C++

Embed Size (px)

DESCRIPTION

OBJECT ORIENTED PROGRAMMING WITH C++

Citation preview

  • Dr.G.R.Damodaran College of Science(Autonomous, affiliated to the Bharathiar University, recognized by the UGC)Re-

    accredited at the 'A' Grade Level by the NAAC and ISO 9001:2008 CertifiedCRISL rated 'A' (TN) for MBA and MIB Programmes

    I B.Sc(Information Technology) [2013 - 2016]II SEMESTER

    CORE : OBJECT ORIENTED PROGRAMMING WITH C - 212AMultiple Choice Questions.

    1. ______________ is an example of Monolithic programming. A. Java. B. BASIC. C. FORTRAN. D. PASCAL. ANSWER: B

    2. _________ is an example for procedural programming. A. Java. B. BASIC. C. FORTRAN. D. PASCAL. ANSWER: C

    3. ______is the fundamental building block of object oriented programming language. A. Module. B. Code. C. Object. D. Function. ANSWER: C

    4. ___________ is one of the ways to achieve polymorphism. A. Inheritance. B. Data overloading. C. Operator overloading. D. Message binding. ANSWER: C

    5. Inline is a _________________. A. variable. B. object. C. keyword. D. class. ANSWER: C

    6. A _______________ is an instance of class. A. code. B. object. C. variable. D. pointer. ANSWER: B

    http://grdmcqonline.com/printqp.php?heading=I B.Sc(Information Tech...

    1 of 20 1/28/2014 3:02 PM

  • 7. Public, private, protected are ______. A. identifiers. B. data members. C. access specifies. D. type of class ANSWER: C

    8. The ______ access specifies allows functions or data to be accessible to other parts of the program. A. private. B. protected. C. public. D. inherited. ANSWER: C

    9. The variable myNum has the value 5. How to print a variable to the screen? A. cout

  • C. constructor. D. pure virtual. ANSWER: D

    15. A continue statement causes execution to skip to ____. A. the first statement after the loop. B. the statement following the continue statement. C. the return 0; statement. D. the next iteration of the loop. ANSWER: D

    16. In a group of nested loops, which loop is executed the most number of times? A. The outermost loop. B. The innermost loop. C. All loops are executed the same number of times. D. Cannot be determined without knowing the size of the loops bottom of form. ANSWER: B

    17. Each pass through a loop is called as ______. A. enumeration. B. iteration. C. culmination. D. pass through. ANSWER: B

    18. In C++, 14 % 4 = ____. A. 1. B. 2 C. 3 D. 4 ANSWER: A

    19. Variables that are declared, but not initialized, contain ________. A. blank spaces. B. zeros. C. "garbage" values. D. nothing - they are empty. ANSWER: C

    20. Array indexing always starts with the ______ number. A. 0 B. 1 C. 2 D. \0 ANSWER: A

    21. When a data type must contain decimal numbers, assign the ______ type. A. int. B. char. C. double. D. long int. ANSWER: C

    22. Set precision requires the header file _____.

    http://grdmcqonline.com/printqp.php?heading=I B.Sc(Information Tech...

    3 of 20 1/28/2014 3:02 PM

  • A. stdlib.h. B. iomanip.h. C. console.h. D. conio.h. ANSWER: B

    23. The memory address of the first element of an array is called ________. A. floor address. B. foundation address. C. first address. D. base address. ANSWER: D

    24. _____ are the variables that contain the address of other variables. A. Function. B. String. C. Pointer. D. Identifier. ANSWER: C

    25. _____ operator returns the address of the identifier. A. &. B. *. C. &&. D. !. ANSWER: A

    26. The ________ operator is used to return the value of the variable to which the pointer points. A. reference. B. dereference. C. dot. D. arrow. ANSWER: B

    27. C++ begins its execution with ____. A. header file. B. main. C. class. D. declaration. ANSWER: B

    28. main() is a______ function. A. built in. B. user defined. C. constant. D. derived. ANSWER: B

    29. ________ is a unary operator that returns the memory address of its operand. A. &. B. ++. C. _ _. D. ||. ANSWER: A

    http://grdmcqonline.com/printqp.php?heading=I B.Sc(Information Tech...

    4 of 20 1/28/2014 3:02 PM

  • 30. ________ is a stream connected to standard output. A. cin. B. gets. C. out. D. cout. ANSWER: D

    31. Which of the following is not a correct data type? A. Float. B. Real. C. Int. D. Double. ANSWER: B

    32. Which of the following is not an arithmetic operator? A. + B. * C. - D. & ANSWER: D

    33. Which is not true about a constructor? A. Constructor should have same name as class name B. It doesnot take any return type C. automatically called D. constructor is compulsary in all program ANSWER: D

    34. Which of the following is a logical operator? A. ++ B. ?: C. == D. && ANSWER: D

    35. What punctuation ends most lines of C++ code? A. . (dot). B. ; (semi-colon). C. : (colon). D. ' (single quote). ANSWER: B

    36. Which of the following is a correct comment? A. */ Comments */. B. ** Comment **. C. /* Comment */. D. { Comment }. ANSWER: C

    37. __________ is the standard input stream. A. cin B. cout C. out

    http://grdmcqonline.com/printqp.php?heading=I B.Sc(Information Tech...

    5 of 20 1/28/2014 3:02 PM

  • D. ios ANSWER: A

    38. __________ is the newline character. A. \t B. \b C. \a D. \n ANSWER: D

    39. When following piece of code is executed, what happens? b = 3; a = b++; A. a contains 3 and b contains 4. B. a contains 4 and b contains 4. C. a contains 4 and b contains 3. D. a contains 3 and b contains 3. ANSWER: A

    40. Which of the following is not a valid relational operator? A. ==. B. =>. C. >=. D. >=. ANSWER: B

    41. __________ is the symbol that precedes the destructor. A. * B. ~ C. & D. @ ANSWER: B

    42. The parameters specified in the function call are known as ____________ parameters A. formal B. actual C. value D. original ANSWER: B

    43. Which of the following will not return a value? A. null B. void C. empty D. free ANSWER: B

    44. _______ have the return type void? A. all functions B. constructors C. destructors D. none of the mentioned ANSWER: D

    45. Function overloading is also similar to which of the following? A. operator overloading

    http://grdmcqonline.com/printqp.php?heading=I B.Sc(Information Tech...

    6 of 20 1/28/2014 3:02 PM

  • B. constructor overloading C. destructor overloading D. none of the mentioned ANSWER: B

    46. The file iostream includes _______. A. The declarations of the basic standard input-output library. B. The streams of includes and outputs of program. C. Comment lines. D. only strings. ANSWER: A

    47. ________ function has access to all private and protected members of the class for which it is afriend. A. Friend. B. Member. C. Nonmember. D. Void. ANSWER: A

    48. _______ function allows to create very efficient code. A. Friend. B. Member. C. Inline. D. Void. ANSWER: C

    49. Which is not a loop structure? A. for. B. do while. C. while. D. repeat until. ANSWER: D

    50. Which of the following is output statement in C++? A. print. B. write. C. cout. D. cin ANSWER: C

    51. The code and data are called ______ of the class. A. instances. B. instance variables. C. members. D. object. ANSWER: C

    52. ________ function is a function that calls itself repeatedly. A. Friend. B. Inline. C. Recursive. D. Member. ANSWER: C

    http://grdmcqonline.com/printqp.php?heading=I B.Sc(Information Tech...

    7 of 20 1/28/2014 3:02 PM

  • 53. ________ is the process of using the same name for two or more functions. A. Function overloading. B. Operator overloading. C. Default function. D. Default function. Constructors. ANSWER: A

    54. A file is closed explicitly using_________. A. fclose(). B. file_close(). C. fin.close(). D. filestream_object.close(). ANSWER: D

    55. Which one of the following reads a single character from file? A. cin(). B. put(). C. get(). D. getw(). ANSWER: C

    56. ___________ is used to write a single character to output file. A. cin(). B. put(). C. get(). D. getw(). ANSWER: B

    57. Which of the following is not an access specifier? A. public B. private C. protest D. protected ANSWER: C

    58. The technique of building new classes from existing classes is called _______. A. inheritance B. overloading C. constructor D. polymorphism ANSWER: A

    59. The class from which another class inherits the property is called __________ class. A. derived B. sub C. subordinate D. base ANSWER: D

    60. Base class is also called as ___________. A. derived B. sub C. super

    http://grdmcqonline.com/printqp.php?heading=I B.Sc(Information Tech...

    8 of 20 1/28/2014 3:02 PM

  • D. subordinate ANSWER: C

    61. The class which derives the property from other is called as ________. A. super B. derived C. subordinarte D. base ANSWER: B

    62. The other name for derived class is __________. A. subclass B. super class C. subordinate class D. base class ANSWER: A

    63. In inheritance, the number of visibility modes are _____. A. 0 B. 1 C. 2 D. 3 ANSWER: D

    64. What does your class can hold? A. data B. functions C. both a & b D. none of the mentioned ANSWER: C

    65. Which is used to define the member of a class externally? A. : B. :: C. # D. none of the mentioned ANSWER: B

    66. ____________ is not an arithmetic operator. A. + B. - C. * D. == ANSWER: D

    67. ____________ is an entry controlled looping statement. A. for B. repeat C. until D. do..while ANSWER: A

    68. Which of the following is an exit controlled looping statement? A. for

    http://grdmcqonline.com/printqp.php?heading=I B.Sc(Information Tech...

    9 of 20 1/28/2014 3:02 PM

  • B. while C. do..while D. repeat ANSWER: C

    69. Which of the following correctly declares an array? A. int array[10]; B. int array; C. array{10}; D. array array[10]; ANSWER: A

    70. What is the index number of the last element of an array with 9 elements? A. 9 B. 8 C. 0 D. Programmer-defined ANSWER: B

    71. What is a array? A. An array is a series of elements of the same type in contiguous memory locations B. An array is a series of element C. An array is a series of elements of the same type placed in non-contiguous memory locations D. None of the above ANSWER: A

    72. Which of the following accesses the seventh element stored in array? A. array[6]; B. array[7]; C. array(7); D. array; ANSWER: A

    73. Pick the odd one out A. array type B. character type C. boolean type D. integer type ANSWER: A

    74. The value 132.54 can represented using which data type? A. double B. void C. int D. bool ANSWER: A

    75. Which key word is used to check exception in the block of code? A. catch B. throw C. try D. none of the above ANSWER: C

    http://grdmcqonline.com/printqp.php?heading=I B.Sc(Information Tech...

    10 of 20 1/28/2014 3:02 PM

  • 76. To where does the program control transfers when exception is arised? A. catch B. handlers C. throw D. except ANSWER: B

    77. Pick out the compound assignment statement. A. a = a - 5 B. a = a / b C. a -= 5 D. a=a+1 ANSWER: C

    78. When a class A inhereits its properties from class B and class C, then the inheritance is said to be___________ inheritance A. multiple B. multilevel C. single D. hybrid ANSWER: A

    79. Polymorphism is not implemented through ____________. A. function overloading B. operator overloading C. virtual functions D. contructors and destructors ANSWER: D

    80. Definition of the function is not necessary in ________. A. virtual functions. B. function overloading C. pure virtual functions. D. operator overloading ANSWER: C

    81. ____________ function specifies the required number of fields to be used while displaying theoutput value. A. with() B. width() C. fill() D. setf() ANSWER: B

    82. _____________ function specifies the number of digits to be displayed after decimal point. A. width() B. precision() C. fill() D. setf() ANSWER: B

    83. ____________ function clears the flags. A. width() B. precision()

    http://grdmcqonline.com/printqp.php?heading=I B.Sc(Information Tech...

    11 of 20 1/28/2014 3:02 PM

  • C. unsetf() D. setf() ANSWER: C

    84. setf() function ______________ A. clears the flags. B. specifies the number of digits to be displayed after decimal point. C. specifies the required number of fields to be used while displaying the output value. D. sets format flags that control the format of output display ANSWER: D

    85. Which of the following is not an inheritance type? A. single inheritance B. multiple inheritance C. multilevel inheritance D. mixed inheritance ANSWER: D

    86. precision() is used to _____________. A. sets format flags that control the format of output display B. specifies the number of digits to be displayed after decimal point. C. clears the flags. D. specifies the required number of fields to be used while displaying the output value. ANSWER: B

    87. ios::right produces the output as ___________. A. left justified B. right justified C. padding between number and the sign. D. decimal conversion ANSWER: A

    88. Which of the following is not a valid file mode? A. ios::in B. ios::out C. ios::truncate D. ios::noreplace ANSWER: C

    89. _____________ is the file mode for opening a file in input mode. A. ios::in B. ios::out C. ios::trunc D. ios::noreplace ANSWER: A

    90. _____________ is the file mode for opening a file in output mode. A. ios::in B. ios::out C. ios::trunc D. ios::noreplace ANSWER: B

    91. _________ allows access to the specific data without need for accessing its preceding its data items.

    http://grdmcqonline.com/printqp.php?heading=I B.Sc(Information Tech...

    12 of 20 1/28/2014 3:02 PM

  • A. sequential file B. random file C. get file D. put file ANSWER: B

    92. Which of the following gives the memory address of a variable pointed to pointer a? A. a. B. *a. C. &a. D. address (a). ANSWER: A

    93. Which one of the following is invalid variable name? A. 1count. B. count. C. count1. D. count_1. ANSWER: A

    94. ________ integer can hold both positive and negative values. A. Unsigned. B. Positive. C. Negative. D. Signed. ANSWER: D

    95. The elements of an array can be accessed by providing integer expression called _______. A. superscripts. B. elements. C. values. D. subscripts. ANSWER: D

    96. The second element of the array in : int zones [5]= { 43,54,56,76,78} can be accessed by ________. A. zones[2]. B. zones[1]. C. zones[3]. D. zones[4]. ANSWER: B

    97. The declaration of a two dimensional array called list with dimensions 4 X 9 is represented as_____.

    A. int list [4] [9]. B. int list [9][4]. C. int list [4,9]. D. int list[9,4]. ANSWER: A

    98. The ______ is the function that detects the end of file. A. eof( ). B. getline( ). C. putline( ). D. clear( ).

    http://grdmcqonline.com/printqp.php?heading=I B.Sc(Information Tech...

    13 of 20 1/28/2014 3:02 PM

  • ANSWER: A

    99. ___________ is not a type of scope in c++. A. Global. B. Local. C. File. D. Function. ANSWER: D

    100. Which of the following is the correct operator to compare two variables? A. :=. B. =. C. equal. D. ==. ANSWER: D

    101. Variables that are declared inside a function are called as ______. A. local. B. global. C. scope. D. external. ANSWER: A

    102. Most of the statement in C++ program should end with ______. A. a full stop (.). B. `a comma (,). C. a semicolon (;). D. a colon (:). ANSWER: C

    103. __________ is a newline character in c++. A. end B. endl C. \t D. ; ANSWER: B

    104. If and the switch statements are called as _____ statements. A. iteration. B. jump. C. selection. D. conditional. ANSWER: C

    105. The switch expression must be of type _______ or _______. A. char, float. B. float, int. C. int, char. D. char, float. ANSWER: C

    106. Find out the error in following block of code. if (x = 100) cout

  • C. Equals to operator mistake. D. Variable x should not be inside quotation. ANSWER: C

    107. Looping in a program means _____. A. jumping to the specified branch of program. B. repeat the specified lines of code. C. execute only once. D. jump to random location of the program. ANSWER: B

    108. The last index of strings contains the _____ null-terminated character. A. \1. B. \t C. \0 D. \n ANSWER: C

    109. If the type specifier of parameters of a function is followed by an ampersand (&), that function callis _______. A. pass by value. B. pass by reference. C. array of structures. D. array of structures. pointers. ANSWER: B

    110. getline() and write() are _________ oriented functions. A. line. B. character. C. data. D. integer. ANSWER: A

    111. Flag value ios:: ________ is used to add + to positive integers. A. showpos. B. showpositive. C. setpos. D. showplus. ANSWER: A

    112. In case of pass by reference ______. A. the values of those variables are passed to the function so that it can manipulate them. B. the location of variable in memory is passed to the function so that it can use the same memoryarea for its processing. C. the function declaration should contain ampersand (&) in its type declaration. D. the function declaration should contain asterisk (*) in its type declaration. ANSWER: B

    113. Overloaded functions are ______. A. very long functions that can hardly run. B. two or more functions with the same name but different number of parameters or type. C. short functions that can easily modified. D. one function containing another one or more functions inside it. ANSWER: B

    http://grdmcqonline.com/printqp.php?heading=I B.Sc(Information Tech...

    15 of 20 1/28/2014 3:02 PM

  • 114. ________ function is a function in which expansion of the function takes place rather thanexecution. A. Friend. B. Inline. C. Recursive. D. Member. ANSWER: B

    115. The name of a function variable or class is called____. A. libraries. B. stream. C. identifiers. D. keywords. ANSWER: C

    116. >> is called as __________ operator. A. insertion. B. extraction. C. greater than. D. lesser than. ANSWER: B

    117.

  • C. ostream. D. fstream. ANSWER: D

    122. ________ is a default access specifier for members of class in C++. A. protected B. public C. private D. default ANSWER: C

    123. A Class can have how many destructor? A. 1 B. 2 C. 3 D. 4 ANSWER: A

    124. The parameter list in function overloading must differ by? A. Number of functions B. Function Size C. Function Name D. Number of argument ANSWER: D

    125. Data members is also called? A. Attribute B. Method C. Class D. Object ANSWER: A

    126. In how many ways is polymorphism achived in C++? A. 2 B. 1 C. 3 D. 4 ANSWER: C

    127. A __________ is a special method used to initialize the instance variable of a class. A. Member function B. Destructor C. Constructor D. Structure ANSWER: C

    128. What features make C++ so powerful? A. Easy implementation B. Code reusability C. Easy memory management D. All the above ANSWER: D

    129. If class A inherits from class B, then B is called _______ of A. A is called ________ of B.

    http://grdmcqonline.com/printqp.php?heading=I B.Sc(Information Tech...

    17 of 20 1/28/2014 3:02 PM

  • A. Super class, Sub class B. Subclass, Super class C. Abstract class, Base Class D. Child class, Sub Class ANSWER: A

    130. ________ is the mechanism which allows a class A to inherit properties of a class B. A. Data abstraction B. Encapsulation C. Inheritance D. Polymorphism ANSWER: C

    131. The mechanism that binds code and data together and keeps them secure from outside world isknown as ___________________ A. Abstraction B. Encapsulation C. Inheritance D. Polymorphism ANSWER: B

    132. Function overloading, operator overloading and virtual functions are the means for implementing_______________.

    A. Abstraction B. Encapsulation C. Inheritance D. Polymorphism ANSWER: D

    133. To overload an operator_________________ keyword must be used along with the operator to beoverloaded. A. Over B. Overload C. void D. Operator ANSWER: D

    134. The first index number in an array starts with _______________ and the index number of an arrayof size n will be _____________. A. 0, n-1 B. 1, n-1 C. 0, n D. 1, n ANSWER: A

    135. What is the output of the program #include void main() { int n=1; cout

  • A. inherit B. auto C. extern D. void ANSWER: A

    137. The expression 5/2 in c++ is evaluated to ____________. A. 2 B. 3 C. 2.5 D. 0 ANSWER: A

    138. The result of the expression 15%3 in c++ is ___________. A. 5 B. 3 C. 0 D. error ANSWER: C

    139. Which of the following is not a bitwise operator? A. ` B. >> C. & D. * ANSWER: D

    140. _____________ is a scope resolution operator. A. : B. :: C. := D. =: ANSWER: B

    141. _______________ operator has the highest priority among the following. A. = B. + C. :: D. () ANSWER: C

    142. An ____________ is a collection of elements of same data type. A. structure B. union C. class D. array ANSWER: D

    143. A function that doesnot return a value will have return type _________________. A. int B. void C. float D. char ANSWER: B

    http://grdmcqonline.com/printqp.php?heading=I B.Sc(Information Tech...

    19 of 20 1/28/2014 3:02 PM

  • 144. ______________ operator has the lowest priority. A. , B. ++ C. * D. + ANSWER: A

    145. ________________ is an increment operator A. + B. > C. ++ D. ?: ANSWER: C

    146. ___________ variables can be initialized only once. A. void B. static C. const D. int ANSWER: B

    147. Static variables can be ______________. A. cannot be created B. initialized only once. C. a constant D. a class ANSWER: B

    148. Who is the father of C+? A. Dennis Ritchie B. Charles Babbage C. Balagurusamy D. Bjarne stroustrup ANSWER: D

    149. _______________ is not a keyword. A. void B. static C. friend D. stack ANSWER: D

    150. _______________ is a keyword. A. queue B. friend C. stick D. stack ANSWER: B

    Staff Name SRIVIDHYA.R.

    http://grdmcqonline.com/printqp.php?heading=I B.Sc(Information Tech...

    20 of 20 1/28/2014 3:02 PM