![Mcqmate logo](https://mcqmate.com/images/logos/logo-black.png)
![Mcqmate logo](https://mcqmate.com/images/logos/logo-white.png)
McqMate
101. |
A private member function can be called by another function that is a member of a class is called |
A. | Friend function |
B. | Nesting of member function |
C. | Inline function |
D. | Static function |
Answer» B. Nesting of member function |
102. |
The function that is a bridge between two classes |
A. | Friend function |
B. | Nesting of member function |
C. | Inline function |
D. | Static function |
Answer» A. Friend function |
103. |
The break statement causes an exit |
A. | from the innermost loop only. |
B. | only from the innermost switch. |
C. | from all loops & switches. |
D. | from the innermost loop or switch. |
Answer» C. from all loops & switches. |
104. |
The arrays of variable that are of the type class |
A. | Array of object |
B. | pointer |
C. | Object |
D. | Structure |
Answer» A. Array of object |
105. |
Which of the following is not a type of constructor? |
A. | Copy constructor |
B. | Friend constructor |
C. | Default constructor |
D. | Parameterized construct |
Answer» B. Friend constructor |
106. |
Which of the following statements is incorrect? |
A. | Friend keyword can be used in the class to allow access to another class. |
B. | Friend keyword can be used for a function in the public section of a class. |
C. | Friend keyword can be used for a function in the private section of a class. |
D. | Friend keyword can be used on main(). |
Answer» D. Friend keyword can be used on main(). |
107. |
Which of the following statement is correct regarding destructor of base class? |
A. | Destructor of base class should always be static. |
B. | Destructor of base class should always be virtual. |
C. | Destructor of base class should not be virtual. |
D. | Destructor of base class should always be private. |
Answer» B. Destructor of base class should always be virtual. |
108. |
How can we make a class abstract? |
A. | By making all member functions constant. |
B. | By making at least one member function as pure virtual function. |
C. | By declaring it abstract using the static keyword. |
D. | By declaring it abstract using the virtual keyword. |
Answer» B. By making at least one member function as pure virtual function. |
109. |
Which of the following statements is correct when a class is inherited publicly? |
A. | Public members of the base class become protected members of derived class. |
B. | Public members of the base class become private members of derived class. |
C. | Private members of the base class become protected members of derived class. |
D. | Public members of the base class become public members of derived class. |
Answer» D. Public members of the base class become public members of derived class. |
110. |
Which of the following access specifies is used in a class definition by default? |
A. | Protected |
B. | Public |
C. | Private |
D. | Friend |
Answer» C. Private |
111. |
Which of the following statement is correct with respect to the use of friend keyword inside a class? |
A. | A private data member can be declared as a friend. |
B. | A class may be declared as a friend. |
C. | An object may be declared as a friend. |
D. | We can use friend keyword as a class name. |
Answer» B. A class may be declared as a friend. |
112. |
Which of the following keywords is used to control access to a class member? |
A. | Default |
B. | Break |
C. | Protected |
D. | Asm |
Answer» C. Protected |
113. |
Which of the following type of data member can be shared by all instances of its class? |
A. | Public |
B. | Inherited |
C. | Static |
D. | Friend |
Answer» C. Static |
114. |
Constructor is executed when _____. |
A. | an object is created |
B. | an object is used |
C. | a class is declared |
D. | an object goes out of scope. |
Answer» A. an object is created |
115. |
Which of the following also known as an instance of a class? |
A. | Friend Functions |
B. | Object |
C. | Member Functions |
D. | Member Variables |
Answer» B. Object |
116. |
How many objects can be created from an abstract class? |
A. | Zero |
B. | One |
C. | Two |
D. | As many as we want |
Answer» A. Zero |
117. |
Which of the following statements is correct? |
A. | Data items in a class must be private. |
B. | Both data and functions can be either private or public. |
C. | Member functions of a class must be private. |
D. | Constructor of a class cannot be private. |
Answer» B. Both data and functions can be either private or public. |
118. |
Which of the following can be overloaded? |
A. | Object |
B. | Functions |
C. | Operators |
D. | Both B and C |
Answer» D. Both B and C |
119. |
Which of the following is the only technical difference between structures and classes in C++? |
A. | Member function and data are by default protected in structures but private in classes. |
B. | Member function and data are by default private in structures but public in classes. |
C. | Member function and data are by default public in structures but private in classes. |
D. | Member function and data are by default public in structures but protected in classes. |
Answer» C. Member function and data are by default public in structures but private in classes. |
120. |
Which of the following statements are correct for a static member function? 1. It can access only other static members of its class. 2. It can be called using the class name, instead of objects. |
A. | Only 1 is correct. |
B. | Only 2 is correct. |
C. | Both 1 and 2 are correct. |
D. | Both 1 and 2 are incorrect. |
Answer» C. Both 1 and 2 are correct. |
121. |
Which of the following means "The use of an object of one class in definition of another class"? |
A. | Encapsulation |
B. | Inheritance |
C. | Composition |
D. | Abstraction |
Answer» C. Composition |
122. |
Which of the following statements is correct when a class is inherited publicly? |
A. | Public members of the base class become protected members of derived class. |
B. | Public members of the base class become private members of derived class. |
C. | Private members of the base class become protected members of derived class. |
D. | Public members of the base class become public members of derived class |
Answer» D. Public members of the base class become public members of derived class |
123. |
Which of the following statements is correct about the constructors and destructors? |
A. | Destructors can take arguments but constructors cannot. |
B. | Constructors can take arguments but destructors cannot. |
C. | Destructors can be overloaded but constructors cannot be overloaded. |
D. | Constructors and destructors can both return a value. |
Answer» B. Constructors can take arguments but destructors cannot. |
124. |
Which of the following statement is correct? |
A. | C++ enables to define functions that take constants as an argument. |
B. | We cannot change the argument of the function that that are declared as constant. |
C. | Both A and B. |
D. | We cannot use the constant while defining the function. |
Answer» C. Both A and B. |
125. |
Which of the following statement is correct? |
A. | Two functions having same number of argument, order and type of argument can be overloaded if both functions do not have any default argument. |
B. | Overloaded function must have default arguments. |
C. | Overloaded function must have default arguments starting from the left of argument list. |
D. | A function can be overloaded more than once. |
Answer» D. A function can be overloaded more than once. |
126. |
Which of the following statement will be correct if the function has three arguments passed to it? |
A. | The trailing argument will be the default argument. |
B. | The first argument will be the default argument. |
C. | The middle argument will be the default argument. |
D. | All the argument will be the default argument. |
Answer» A. The trailing argument will be the default argument. |
127. |
Which of the following statement is incorrect? |
A. | Default arguments can be provided for pointers to functions. |
B. | A function can have all its arguments as default. |
C. | Default argument cannot be provided for pointers to functions. |
D. | A default argument cannot be redefined in later declaration. |
Answer» C. Default argument cannot be provided for pointers to functions. |
128. |
Which of the following statement is correct? |
A. | Constructors can have default parameters. |
B. | Constructors cannot have default parameters. |
C. | Constructors cannot have more than one default parameter. |
D. | Constructors can have at most five default parameters. |
Answer» A. Constructors can have default parameters. |
129. |
Which of the following function / type of function cannot be overloaded? |
A. | Member function |
B. | Static function |
C. | Virtual function |
D. | Both B and C |
Answer» C. Virtual function |
130. |
Which of the following statement is incorrect? |
A. | The default value for an argument can be a global constant. |
B. | The default arguments are given in the function prototype. |
C. | Compiler uses the prototype information to build a call, not the function definition. |
D. | The default arguments are given in the function prototype and should be repeated in the function definition. |
Answer» D. The default arguments are given in the function prototype and should be repeated in the function definition. |
131. |
Where the default value of parameter have to be specified? |
A. | Function call |
B. | Function definition |
C. | Function prototype |
D. | Both B or C |
Answer» C. Function prototype |
132. |
Which of the following statement is correct? |
A. | The default value for an argument cannot be function call. |
B. | C++ allows the redefinition of a default parameter. |
C. | Both A and B. |
D. | C++ does not allow the redefinition of a default parameter. |
Answer» D. C++ does not allow the redefinition of a default parameter. |
133. |
Which of the following statement is correct? |
A. | Only one parameter of a function can be a default parameter. |
B. | Minimum one parameter of a function must be a default parameter. |
C. | All the parameters of a function can be default parameters. |
D. | No parameter of a function can be default. |
Answer» C. All the parameters of a function can be default parameters. |
134. |
Which of the following function / types of function cannot have default parameters? |
A. | Member function of class |
B. | main() |
C. | Member function of structure |
D. | Both B and C |
Answer» B. main() |
135. |
A constructor that accepts __________ parameters is called the default constructor. |
A. | one |
B. | two |
C. | no |
D. | three |
Answer» C. no |
136. |
What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero‐argument constructor? |
A. | Compile‐time error. |
B. | Preprocessing error. |
C. | Runtime error. |
D. | Runtime exception. |
Answer» A. Compile‐time error. |
137. |
Destructor has the same name as the constructor and it is preceded by ______ . |
A. | ! |
B. | ? |
C. | ~ |
D. | $ |
Answer» C. ~ |
138. |
For automatic objects, constructors and destructors are called each time the objects |
A. | enter and leave scope |
B. | inherit parent class |
C. | are constructed |
D. | are destroyed |
Answer» A. enter and leave scope |
139. |
Which constructor function is designed to copy objects of the same class type? |
A. | Create constructor |
B. | Object constructor |
C. | Dynamic constructor |
D. | Copy constructor |
Answer» D. Copy constructor |
140. |
Which of the following statement is correct? |
A. | Constructor has the same name as that of the class. |
B. | Destructor has the same name as that of the class with a tilde symbol at the beginning. |
C. | Both A and B. |
D. | Destructor has the same name as the first member function of the class. |
Answer» C. Both A and B. |
141. |
When are the Global objects destroyed? |
A. | When the control comes out of the block in which they are being used. |
B. | When the program terminates. |
C. | When the control comes out of the function in which they are being used. |
D. | As soon as local objects die. |
Answer» B. When the program terminates. |
142. |
Copy constructor must receive its arguments by __________ . |
A. | either pass‐by‐value or pass‐by‐reference |
B. | only pass‐by‐value |
C. | only pass‐by‐reference |
D. | only pass by address |
Answer» C. only pass‐by‐reference |
143. |
A function with the same name as the class, but preceded with a tilde character (~) is called __________ of that class. |
A. | constructor |
B. | destructor |
C. | function |
D. | object |
Answer» B. destructor |
144. |
Which of the following gets called when an object goes out of scope? |
A. | constructor |
B. | destructor |
C. | main |
D. | virtual function |
Answer» B. destructor |
145. |
_________ used to make a copy of one class object from another class object of the same class type. |
A. | constructor |
B. | copy constructor |
C. | destructor |
D. | default constructor |
Answer» B. copy constructor |
146. |
Constructors __________ to allow different approaches of object construction. |
A. | cannot overloaded |
B. | can be overloaded |
C. | can be called |
D. | can be nested |
Answer» B. can be overloaded |
147. |
Which of the following cannot be declared as virtual? |
A. | Constructor |
B. | Destructor |
C. | Data Members |
D. | Both A and C |
Answer» A. Constructor |
148. |
If the copy constructor receives its arguments by value, the copy constructor would |
A. | call one‐argument constructor of the class |
B. | work without any problem |
C. | call itself recursively |
D. | call zero‐argument constructor |
Answer» C. call itself recursively |
149. |
Which of the following are NOT provided by the compiler by default? |
A. | Zero‐argument Constructor |
B. | Destructor |
C. | Copy Constructor |
D. | Copy Destructor |
Answer» D. Copy Destructor |
150. |
It is a __________ error to pass arguments to a destructor. |
A. | logical |
B. | virtual |
C. | syntax |
D. | linker |
Answer» C. syntax |
151. |
A __________ is a constructor that either has no parameters, or if it has parameters, all the parameters have default values. |
A. | default constructor |
B. | copy constructor |
C. | Both A and B |
D. | None of these |
Answer» A. default constructor |
152. |
How many default constructors per class are possible? |
A. | Only one |
B. | Two |
C. | Three |
D. | Unlimited |
Answer» A. Only one |
153. |
Which of the following statement is correct? |
A. | A constructor has the same name as the class in which it is present. |
B. | A constructor has a different name than the class in which it is present. |
C. | A constructor always returns an integer. |
D. | A constructor cannot be overloaded. |
Answer» A. A constructor has the same name as the class in which it is present. |
154. |
A destructor takes __________ arguments. |
A. | one |
B. | two |
C. | three |
D. | no |
Answer» D. no |
155. |
Destructor calls are made in which order of the corresponding constructor calls? |
A. | Reverse order |
B. | Forward order |
C. | Depends on how the object is constructed |
D. | Depends on how many objects are constructed |
Answer» A. Reverse order |
156. |
Which of the following never requires any arguments? |
A. | Member function |
B. | Friend function |
C. | Default constructor |
D. | const function |
Answer» C. Default constructor |
157. |
A class's __________ is called when an object is destroyed. |
A. | constructor |
B. | destructor |
C. | assignment function |
D. | copy constructor |
Answer» B. destructor |
158. |
How many times a constructor is called in the life‐time of an object? |
A. | Only once |
B. | Twice |
C. | Thrice |
D. | Depends on the way of creation of object |
Answer» A. Only once |
159. |
To ensure that every object in the array receives a destructor call, always delete memory allocated as an array with operator __________ . |
A. | destructor |
B. | New[] |
C. | delete[] |
D. | Free() |
Answer» C. delete[] |
160. |
Which of the following statement is correct whenever an object goes out of scope? |
A. | The default constructor of the object is called. |
B. | The parameterized destructor is called. |
C. | The default destructor of the object is called. |
D. | None of the above. |
Answer» C. The default destructor of the object is called. |
161. |
Which allows you to create a derived class that inherits properties from more than one base class? |
A. | Multilevel inheritance |
B. | Multiple inheritance |
C. | Hybrid Inheritance |
D. | Hierarchical Inheritanc |
Answer» B. Multiple inheritance |
162. |
Which feature in OOP allows reusing code? |
A. | Polymorphism |
B. | Inheritance |
C. | Encapsulation |
D. | Data hiding |
Answer» B. Inheritance |
163. |
The mechanism of deriving a new class from another class |
A. | Polymorphism |
B. | Inheritance |
C. | Encapsulation |
D. | Data hiding |
Answer» B. Inheritance |
164. |
A derived class with only one base class |
A. | Multilevel inheritance |
B. | Multiple inheritance |
C. | Single inheritance |
D. | Hierarchical Inheritance |
Answer» C. Single inheritance |
165. |
The mechanism of deriving one base class with more than one derived classes |
A. | Multilevel inheritance |
B. | Multiple inheritance |
C. | Hybrid Inheritance |
D. | Hierarchical Inheritance |
Answer» D. Hierarchical Inheritance |
166. |
The duplication of inherited members due to the multiple paths can be avoided by making a common base class is called |
A. | Abstract class |
B. | Virtual base class |
C. | Multiple inheritance |
D. | Nesting of classes |
Answer» B. Virtual base class |
167. |
The class that is not used to create object |
A. | Abstract class |
B. | Virtual base class |
C. | Multiple inheritance |
D. | Nesting of classes |
Answer» A. Abstract class |
168. |
The mechanism of giving special meaning to an operator |
A. | Operator overloading |
B. | Function overloading |
C. | Constructor overloading |
D. | Virtual function |
Answer» A. Operator overloading |
169. |
The operators can’t be overloaded |
A. | Binary operators |
B. | Unary operators |
C. | Ternary operator |
D. | None |
Answer» C. Ternary operator |
170. |
Which of the following is not correct |
A. | Only existing operator can be overloaded |
B. | The overloaded operator must have at least one operand |
C. | We can change the basic meaning of the operator |
D. | Overloaded operators follow the syntax rule of original operator |
Answer» C. We can change the basic meaning of the operator |
171. |
The operator we cannot use friend function |
A. | ? |
B. | Sizeof |
C. | :: |
D. | [] |
Answer» D. [] |
172. |
A friend function for unary operator overloading takes ‐‐‐‐ ‐arguments. |
A. | Zero |
B. | One |
C. | Two |
D. | None |
Answer» B. One |
173. |
A member function for unary operator overloading takes‐‐‐‐ ‐arguments. |
A. | Zero |
B. | One |
C. | Two |
D. | None |
Answer» A. Zero |
174. |
A friend function for binary operator overloading takes‐‐‐‐ ‐arguments. |
A. | Zero |
B. | One |
C. | Two |
D. | None |
Answer» C. Two |
175. |
The variable that contains the address of constant or variable |
A. | Function |
B. | Array |
C. | pointer |
D. | structure |
Answer» C. pointer |
176. |
The indirect operator is |
A. | & |
B. | * |
C. | :: |
D. | :? |
Answer» B. * |
177. |
The memory management operator in c++ |
A. | new &delete |
B. | malloc |
C. | calloc |
D. | free |
Answer» A. new &delete |
178. |
The pointer refers to an object that has called the member function currently |
A. | this |
B. | address |
C. | virtual function |
D. | none |
Answer» A. this |
179. |
Conversion of data type is called |
A. | self referencing |
B. | type casting |
C. | virtual function |
D. | abstract class |
Answer» B. type casting |
180. |
The function that act as an interface to base & derived class |
A. | function overloading |
B. | virtual function |
C. | constructor |
D. | friend |
Answer» B. virtual function |
181. |
The keyword to convert constant into variable |
A. | Const_cast |
B. | reinterpret_cast |
C. | static_cast |
D. | implicit |
Answer» A. Const_cast |
182. |
The keyword to convert pointer into non pointer & non pointer into pointer |
A. | Const_cast |
B. | reinterpret_cast |
C. | static_cast |
D. | implicit |
Answer» B. reinterpret_cast |
183. |
Treating the address of the object of the derived class as the address of the base class means |
A. | Up casting |
B. | down casting |
C. | early binding |
D. | late binding |
Answer» A. Up casting |
184. |
The empty virtual function are called |
A. | pure /donothing |
B. | virtual table |
C. | polymorphism |
D. | virtual base class |
Answer» A. pure /donothing |
185. |
A stream of byte that is the interface between IO and IO devices |
A. | Streams |
B. | class |
C. | object |
D. | file |
Answer» A. Streams |
186. |
The class that derived from standard library ios contain input functions |
A. | Ios |
B. | iostream |
C. | istream |
D. | ostream |
Answer» C. istream |
187. |
The class that derived from standard library ios contain output functions |
A. | Ios |
B. | iostream |
C. | istream |
D. | ostream |
Answer» D. ostream |
188. |
Which function is in the ostream class |
A. | get() |
B. | read() |
C. | write |
D. | cin |
Answer» C. write |
189. |
Which function is in the istream class |
A. | get() |
B. | put() |
C. | write |
D. | cout |
Answer» A. get() |
190. |
The standard library inherited from istream & ostream |
A. | Ios |
B. | iostream |
C. | ifstream |
D. | ofstream |
Answer» B. iostream |
191. |
The function used to receive one character at a time |
A. | get() |
B. | put() |
C. | getline() |
D. | write() |
Answer» A. get() |
192. |
The function used to disply one character at a time |
A. | get() |
B. | put() |
C. | getline() |
D. | write() |
Answer» B. put() |
193. |
The function used to receive one line at a time |
A. | get() |
B. | put() |
C. | getline() |
D. | write() |
Answer» C. getline() |
194. |
The function used to display one line at a time |
A. | get() |
B. | put() |
C. | getline() |
D. | write() |
Answer» D. write() |
195. |
The function contain in the ios class to set width |
A. | width() |
B. | precision() |
C. | fill() |
D. | setf() |
Answer» A. width() |
196. |
The function contain in the class iomanip to set width |
A. | setw() |
B. | set precision() |
C. | set fill() |
D. | setiosflags() |
Answer» A. setw() |
197. |
The function contain in the class iomanip to fill characters in the un used space |
A. | setw() |
B. | set precision() |
C. | set fill() |
D. | setiosflags() |
Answer» C. set fill() |
198. |
The function contain in the ios class to fill characters in the blank space |
A. | width() |
B. | precision() |
C. | fill() |
D. | setf() |
Answer» C. fill() |
199. |
The function contain in the ios class to specify number of decimal places |
A. | width() |
B. | precision() |
C. | fill() |
D. | setf() |
Answer» B. precision() |
200. |
The function contain in the ios class to set flags |
A. | width() |
B. | precision() |
C. | fill() |
D. | setf() |
Answer» D. setf() |
Done Reading?