web viewwhich of the following statements can be overloaded?a) size of operatorb) scope resolution...
TRANSCRIPT
SNJB’s KBJ COE, CHANDWADDEPARTMENT OF COMPUTER ENGINEERING
MULTIPLE CHOICE QUESTIONS
Faculty : Mrs. K.M.Sanghavi
Subject : Object Oriented Programming Semester : IClass:S.E Academic Year : 2016-17
UNIT I and II
1. An entity representing some characteristics and behaviour is-a) objectb) classc) structd) none of the above
2. Which of the following is not the feature of OOPs?a) Data Encapsulationb) Inheritancec) Polymorphismd) None of the above
3. The wrapping up of data and functions into a single unit isa) Data Abstractionb) Data Encapsulationc) Both (a) & (b)d) None of the above
4. Which of the following feature supports reusability and extensibility of classes?a) Inheritanceb) Overloadingc) Polymorphismd) None of the above
5. Inheritance is ………..in nature.a) Intransitiveb) Transitivec) Both (a) & (b)d) None of the above
6. ………… is the ability for a message or data to be processed in more than one forma) Classb) Abstractionc) Polymorphismd) None of the above
7. The smallest individual unit in a program is ………a) Keywordb) Identifierc) Tokend) None of the above
8. Which of the following features of procedure oriented programming is falsea) Large programs are divided into small or units called functions.b) Employs bottom-up approach in program design.c) Most of the functions share global data.d) None of the above.
9. Which of the following features of object oriented programming is false?a) Data is hidden and is not available to external functions.b) New data & functions can be added easily.c) Objects may communicate with each other through functions.d) Emphasis is on the procedure rather than data.
10. The following is the C++ style commenta) //b) /*..*/c) —d) None of the above
11. Which of the following statements is false?a) Every C++ program must have a main().b) In C++, white spaces and carriage returns are ignored by the compiler.c) C++ statements terminate with semicolon.d) Main() terminates with semicolon.
12. An identifier in C++a) Must begin with a letter onlyb) Is not differentiated by casesc) Contains all characters as significantd) None of the above
13. 010 is an example ofa) decimal constantb) octal constantc) hexadecimal constantd) None of the above
14. A sequence of characters surrounded by double quotes isa) Character literalb) String literalc) Both (a) & (b)d) None of the above
15. The following data type specifies an empty set of valuesa) Void
b) Intc) Chard) None of the above
16. ………. Provides a value for a variablea) declaration statementb) assignment statementc) definition statementd) None of the above
17. A collection of variables referred under one namea) Structureb) Classc) Uniond) None of the above
18. A memory location shared by two or more different variablesa) Structureb) Classc) Uniond) None of the above
19. The constants defined using enum keyword area) Symbolsb) Enumeratorsc) Keywordsd) None of the above
20. The operator ?: isa) Logical operatorb) Relational operatorc) Conditional operatord) Arithmetic operator
21. A loop containing other loop isa) Nestedb) Innerc) Outerd) None of the above
22. The following statement forces the next iteration of the loop to take placea) breakb) continuec) gotod) None of the above
23. gets() function is available ina) stdio.hb) string.h
c) ctype.hd) stdlib.h
24. In C++, the statements are enclosed withina) parenthesisb) square bracketsc) curly bracketsd) None of the above
25. The following tells the compiler where the program beginsa) Function prototypeb) Forward declaration of classc) main()d) None of the above
26. << operator isa) stream insertion operatorb) stream extraction operatorc) left shift operatord) None of the above
27. “H” is an example ofa) character literalb) string literalc) variabled) None of the above
28. Which of the following statements regarding comments is false?a) /*..*/b) Comment beginning with // extends to the end of the linec) Comments may be nestedd) Comments are used to describe a program
29. C++ isa) Procedural programming languageb) Structural programming languagec) Object oriented programming languaged) None of the above
30. y=x=2; in C++ will result ina) compilation errorb) runtime errorc) assignment of value to x then to yd) None of the above
31. In C++, ………. is the statement terminatora) semicolonb) colonc) new lined) None of the above
32. Modules operator (%) has higher precedence thana) Divide (/) operatorb) Multiply (*) operatorc) Negation (unary minus)d) Bitwise left shift operator
33. The result of the following statement isint y = 7;int ans = ++y;cout<<”ans=”<<ans;cout<<”y”<<y;
a) ans=7, y=7b) ans=8,y=7c) ans=8,y=8;d) none of the above
34. Consider the following if constructIf(x=0)cout<<”Inside loop!”;cout<<”Outside loop”;The result of the above code segment is.
a) inside loopb) outside loopc) both (a) & (b)d) none of the above
35. The result of 2 & 3 isa) 2b) 3c) 5d) none of the above
36. Which of the following statements regarding enumerators is false?a) Enumeration is an alternative method for naming integer constants/b) An enumerator value can’t be changed in a programc) An integer value may be assigned to an enumerated variabled) An enum defined within a structure is local to the structure
37. Which of the following statements is false?a) typedef defines new data typesb) Using typedef does not replace the standard C++ data type name with the new namec) The new name defined by typedef, can be used as a type for another typedefd) None of the above
38. Data members and member functions are enclosed withina) classb) structure
c) uniond) None of the above
39. Inline functions area) Declared in the class defined outside the classb) Defined outside the class using keyword intimec) Defined inside the class using keyword inlined) None of the above
40. The default class access scope isa) Privateb) Publicc) Protectedd) None of the above
41. The default scope for a structure isa) Privateb) Publicc) Protectedd) None of the above
42. The private data members of a class are accessiblea) Directly to objects of that classb) Only to the member functionsc) To any function defined outside a classd) None of the above
43. The objects can directly accessa) Public membersb) Private membersc) Both (a) & (b)d) None of the above
44. The following is a valid statement in C++a) int x=(int)2.50;b) int x=int(2.50);c) Both (a) & (b)d) None of the above
45. Which of the following operator can be overloadeda) Member access operator ( . & .*)b) Conditional operator (?:)c) Scope resolution operator (::)d) None of the above
46. Using same function name to perform different tasks isa) Function polymorphismb) Runtime polymorphismc) Function prototyped) None of the above
47. Default argument isa) Specified in function definitionb) Specified in function declarationc) Specified from left to rightd) None of the above
48. What is wrong with the following statement?float s_interest (float principal, int rate=0.25, int time);
a) variables must not be specified in function prototypeb) arguments may only be defaulted from right to leftc) the default value must be specified when making a function calld) none of the above
49. Which of the following statements regarding function overloading is not true.a) If is used to handle different data types at one placeb) When making a function call, if no exact match is found, promotion is the only criteria to find a match.c) The default arguments can not be used instead of overloadingd) Unrelated functions should not be overloaded
50. The private members of a class implement the OOP concept ofa) Data abstractionb) Data hidingc) Message passingd) None of the above
51. When a member function of a class call another member function, it isa) Nesting of classesb) Nesting of functionsc) Nesting of objectsd) None of the above
52. A function defined inside a class is calleda) A class functionb) A friend functionc) A member functiond) None of the above
53. Information is made shareable througha) inheritanceb) data encapsulationc) data abstractiond) none of the above
54. Functions can returnsa) arraysb) referencec) objectd) all of the above
55. The memory for date members is allocateda) When a class is definedb) When an object is initializedc) When an object is createdd) None of the above
56. The memory for member functions is allocateda) When a class is definedb) When a object is createdc) When an object is initializedd) None of the above
57. The dot operator relatesa) A class member and a class objectb) A class object and a classc) A class and a member of that classd) A class object and member of that class
58. A class having another class definition isa) Nested classb) Subordinate classc) Enclosing classd) None of the above
59. A class whose member functions are friends of other class isa) Friend classb) Abstract classc) Virtual classd) None of the above
60. The data members of a class are initializeda) in class definitionb) by a non-member functionc) through constructor function when a class object is createdd) none of the above
61. A constructor function isa) A friend function to a classb) A member function with the same name as its classc) A non-member functiond) None of the above
62. An enumerated type is composed ofa) Integer values with user defined nameb) Variables of different data typesc) Constant numeric valuesd) None of the above
63. In C++, the arguments by default are passed bya) call be reference
b) call be valuec) both (a) & (b)d) none of the above
64. ? is an example ofa) unary operatorb) binary operatorc) ternary operatord) none of the above
65. new operator is useda) to define a new variableb) to create a new data typec) to allocate memory dynamicallyd) none of the above
66. A constructor function is generally defineda) In the public section of a classb) In the private section of a classc) In the protected section of a classd) None of the above
67. A class having no public constructors isa) A private classb) A public classc) An abstract classd) None of the above
68. If a constructor function is defined in private section of a class, thena) The object cannot be createdb) Only member functions and friends may declare objects of the classc) Both (a) & (b)d) None of the above
69. A constructor with no argument isa) Default constructorb) Parameterized constructorc) Copy constructord) None of the above
70. If default arguments are provided to a constructor function, then it becomesa) Default constructorb) Copy instructorc) Parameterized constructord) None of the above
71. The class of which the objects are not instantiated isa) Abstract classb) Virtual class
c) Static classd) None of the above
72. && denotesa) logical ORb) logical ANDc) Bitwise ANDd) None of the above
73. The parameterized constructora) Needs initial values as arguments during creation of an objectb) Can be invoked explicitly onlyc) Can be invoked implicitly onlyd) None of the above
74. Explicit call to a constructor meansa) Providing the constructor name explicitly to invoke itb) Not providing the construction name at allc) Is the shorthand methodd) None of the above
75. Classes in C++ area) Fundamental data typeb) Primitive data typec) Desired data typed) None of the above
76. A copy constructor is calleda) When an object is defined and initialized with another objectb) When an object is passed by valuec) When a function returns an objectd) All of the above
77. Which of the following regarding constructor function is false?a) Constructor functions don’t have return type, not even voidb) Constructors can’t be inheritedc) We can refer to their addressesd) Constructors cannot be virtual
78. If new operator is used, then the constructor function isa) Parameterized constructorb) Copy constructorc) Dynamic constructord) Default constructor
79. Which of the following statements regarding constructor is false?a) A constructor may be defined staticb) Constructor can have default argumentsc) Member functions may be invoked from within a constructord) None of the above
80. The antonym of constructor isa) Creatorb) Destructorc) Destroyerd) None of the above
81. Variable …………. of void typea) May be declaredb) Cannot be declaredc) Can be initializedd) None of the above
82. A destruction functiona) Takes no argument and has no return type not even voidb) Has name similar to that of class, preceded by tilde(~) symbolc) Is used to destruct an object, constructed through constructor functiond) All of the above
83. Which of the following statements regarding destructor function is false?a) Destructors do not accept any arguments, nor do they return any valuesb) Destructors can be inheritedc) Member functions may be called from within a destructord) Destructor functions are called automatically when an object is destroyed
84. Function overloadinga) Involves several function definitions under one name, but different argument typesb) Implements polymorphismc) Reduces the number of comparison in a program, hence increases the execution speed of a programd) All of the above
85. The signature of function isa) The number & type of argumentsb) The return type of a functionc) The class definitiond) None of the above
86. Overloading of constructor functiona) is similar to function overloadingb) different from an overloaded function as it can’t return a valuec) not permitted in C++d) none of the above
87. The binding of a function call at runtime isa) Static bindingb) Early bindingc) Late bindingd) Runtime binding
88. The process of giving special meaning to an operator isa) Operator overloadingb) Operator mechanismc) Operator definitiond) None of the above
89. The function used to define the task assigned to an operator isa) Virtual functionb) Operator functionc) Static functiond) None of the above
90. The following operators can not be overloadeda) Unary operatorb) Binary operatorc) Ternary operatord) None of the above
91. Which of the following statements regarding operator overloading is not true?a) New operators cannot be created while overloadingb) The semantics of an operator cannot be changed while overloadingc) Subscript operator([]) can be overloadedd) None of the above
92. Which of the following statements can be overloaded?a) Size of operatorb) Scope resolution operator (::)c) Class member access operator (->)d) Pointer to member operator
93. Operator functionsa) Can return a valueb) Cannot return a valuec) May return values of limited data typesd) None of the above
94. While overloading, a unary operatora) Takes no argumentsb) Takes one argumentc) Takes two argumentsd) None of the above95. While overloading, a binary operatora) takes no argumentb) takes one argumentc) takes two argumentsd) none of the above
96. Which of the following operators cannot be overloaded?a) increment and decrement operatorb) function call operator, ()
c) subscript operator, []d) none of the above
97. When an arithmetic assignment operator is overloaded, the resulta) goes in the object to the left of the operatorb) goes in the object to the right of the operatorc) goes in the object of which the operator is a memberd) none of the above
98. The function that overloads as operator, precedes with the keyworda) functionb) operatorc) virtuald) static
99. The symbol **a) can be overloadedb) cannot be overloaded as it is not a C++ operatorc) cannot be overloaded, as on overloading its meaning shall be changedd) none of the above
100. The stream insertion and extraction operators should be overloaded asa) friend functionsb) member functionc) non member functionsd) none of the above
101. The following operators cannot be overloadeda) scope resolution operatorb) size of operatorc) conditional operatord) all of the above
102. The operator definition precedes with the keyword classa) classb) operatorc) overloadd) none of the above
103. The operator functiona) is declared in the public section of the classb) may be a member function or a friend functionc) both (a) & (b)d) none of the above
104. The operator functions may be invokeda) implicitlyb) explicitlyc) both (a) & (b)d) none of the above
105. The following operator can’t be overloadeda) unaryb) binaryc) ternaryd) none of the above
106. Which of the following statements regarding operator overloading function is false?a) While overloading, the semantics of an operator cannot be changed.b) The operator precedence cannot be changed while overloading.c) The overloaded operator must have at least one operand that is of user-defined type.d) You can create new operator symbol.
107. The following operators cannot be overloaded.a) Logical AND (&&)b) Subscript operator ([])c) Equality operator (==)d) none of the above
108. A unary operator when overloaded takesa) no operandb) one operandc) two operandsd) none of the above]
109. The no of arguments required when overloading through friend functions isa) Zerob) Onec) Twod) None of the above
110. Which of the following statements regarding operator overloading is false?a) friend function cannot be used to overload certain operators.b) Unary operators overloaded by means of friend functions takes no argumentc) Binary operators must explicitly return a valued) The syntax rules of the operators cannot be overridden.
111. The following feature supports extensibility and reusability of classesa) function overloadingb) inheritancec) operator overloadingd) data encapsulation
112. The process of deriving a class from another derived class isa) single inheritanceb) multilevel inheritancec) multiple inheritanced) none of the above
113. When a derived class inherits only from one class and is not further inherited isa) single inheritanceb) multiple inheritancec) multilevel inheritanced) hybrid inheritance
114. When a derived class inherits from may base classes it isa) multilevel inheritanceb) single inheritancec) multiple inheritanced) none of the above
115. Inheritance is ……….. in naturea) transitiveb) intransitivec) both (a) & (b)d) none of the above
116. ……………. variables cannot be declareda) structureb) pointerc) voidd) class
117. When a subclass inherits from multiple base classes, which inherits from a single class, the inheritance type isa) single inheritanceb) hybrid inheritancec) multilevel inheritanced) multiple inheritance
118. When one class inherits from the base class, then the original class is calleda) base classb) derived classc) sub classd) none of the above
119. The default visibility mode while inheriting isa) privateb) publicc) protectedd) none of the above
120. The class intended to be a base class should use visibility mode asa) publicb) protectedc) privated) Both (a) & (b)
121. Operator overloading isa) making c++ operators work with objectsb) giving c++ operators more than they can handlec) giving new meaning to existing c++ operatorsd) making new c++ operators
122. To convert from a user defined class to a basic type, you would most likely usea) a built-in conversion functionb) a one-argument constructorc) an overloaded-operatord) a conversion function that’s member of the class
123. The members of a classa) by default are publicb) by default are privatec) are made private by declaring as privated) none of the above]
124. The following symbol indicates the derived class is derived from the base classa) ::b) :c) ->d) none of the above
125. When a base class publicly inheriteda) the public members of the base class are inherited as privateb) the private members are inherited as privatec) the protected members are inherited as protectedd) none of the above
126. When a base class is privately inherited by derived classa) the public members of the base class becomes the private members of the derived classb) the private members are not inheritedc) the protected members of the base class becomes the private members of the derived classd) All of the above
127. Only one copy of the class is inherited, when it is defined asa) virtualb) staticc) publicd) none of the above
128. A class that acts only as a base class and is not used to create objects isa) parent classb) super classc) abstract classd) none of the above
129. The version of a virtual function actually gets called during runtime is based solely up in the type of the object that isa) being instantiated and processed by the functionb) in the derived classc) being pointed to by a base class pointerd) being passed to the function
130. In multiple inheritance, the base classes are constructeda) in the order of declaration in the derived classb) in the order of declaration in the program.c) in the order of definition of a classd) none of the above
131. When an object of a derived class is createda) derived class constructor is called followed by base class constructorb) base class constructor is called followed by derived class constructorc) base class constructor is not called at alld) none of the above
132. The derived class constructora) never passes any values to base class constructorb) is responsible for passing the entire test of arguments needed by base class constructorsc) can pass arguments only to one base class constructor functiond) none of the above
133. A virtual base classa) allows to inherit more than one copy of the base class membersb) strict the path of inheritancec) is qualified as virtual in base class definitiond) none of the above
134. When a base class is inherited publiclya) the private members of the base class are not accessibleb) the derived class can directly access the private members of the base classc) the derived class can access the private members only through the member function of the base classd) none of the above
135. When two or more classes are used within another class definition, it isa) inheritanceb) aggregationc) both (a) & (b)d) none of the above
136. Composition is referred to asa) “is a” relationshipb) “has a” relationshipc) both (a) & (b)d) none of the above
137. Inheritance is referred to asa) “is a” relationshipb) “has a” relationshipc) Both (a) & (b)d) none of the above
138. An explicitly defined destructor functiona) may be virtualb) may not be virtualc) both (a) & (b)d) None of the above
139. The copy operation by a simple assignment causes in some casesa) no effectb) hollow copyc) copy exactly the same as originald) creates new
140. Public data members can be accesseda) only from the base class itselfb) both form the base class and from its derived classc) from the class which is a friend of the base classd) none of the above
141. A static automatic variable is used toa) make a variable visible to several functionb) make a variable visible only to one functionc) converse memory when a function is not executingd) retain a value when a function is not executing
142. The stacks data structure are based ona) LIFOb) FILOc) FIFOd) None of the above
143. Queues are based ona) LIFOb) FILOc) FIFOd) None of the above
144. & operator isa) indirection operatorb) Logical ANDc) address operatord) none of the above
145. int *ptr[10]; isa) an array of 10 int pointers
b) a pointer of 10 int elementsc) an array of 10 elements returning an int valued) none of the above
146. A structure that refers to itself is aa) nested structureb) recursive structurec) self-referential structured) none of the above
147. With in …….scope class member may be referenced simply by their namesa) class’sb) object’sc) programd) none of the above
148. To point to the address of any pointer variable cast the pointer toa) char *b) int *c) void *d) none of the above
149. Destructors are calleda) in the same order of constructor callsb) in the reverse order of constructor callsc) in any random orderd) none of the above
150. The advantage of declaring a virtual function as pure isa) you can avoid making the class an abstract classb) you force any derived class to define its own implementationc) programs runs fasterd) early binding can be achieved
Solution Set to Multiple Choice Questions
(1) A (2) D (3) B (4) A
(5) B (6) C (7) C (8) B
(9) D (10) A (11) D (12) C
(13) B (14) B (15) A (16) B
(17) A (18) C (19) B (20) C
(21) A (22) B (23) A (24) C
(25) C (26) A (27) B (28) C
(29) C (30) C (31) A (32) C
(33) C (34) B (35) A (36) C
(37) A (38) A (39) B (40) A
(41) B (42) B (43) A (44) C
(45) D (46) A (47) B (48) B
(49) C (50) B (51) B (52) C
(53) A (54) D (55) B (56) A
(57) D (58) C (59) A (60) C
(61) B (62) A (63) B (64) C
(65) C (66) A (67) A (68) C
(69) A (70) A (71) A (72) B
(73) A (74) A (75) C (76) D
(77) C (78) C (79) A (80) B
(81) B (82) D (83) B (84) D
(85) A (86) B (87) C (88) A
(89) B (90) C (91) D (92) C
(93) A (94) A (95) B (96) D
(97) A (98) B (99) B (100) A
(101) D (102) B (103) C (104) C
(105) C (106) D (107) D (108) B
(109) C (110) B (111) B (112) B
(113) A (114) C (115) A (116) C
(117) B (118) A (119) A (120) D
(121) C (122) D (123) B (124) B
(125) C (126) D (127) A (128) C
(129) C (130) A (131) B (132) B
(133) C (134) C (135) B (136) B
(137) A (138) A (139) B (140) C
(141) C (142) A (143) C (144) C
(145) A (146) C (147) A (148) C
(149) B (150) B