MCQOPTIONS
Saved Bookmarks
This section includes 916 Mcqs, each offering curated multiple-choice questions to sharpen your Technical Programming knowledge and support exam preparation. Choose a topic below to get started.
| 151. |
Which constructor definition will produce a compile time error? |
| A. | className(int x=0); |
| B. | className(char c); |
| C. | className(int x=0,char c); |
| D. | className(char c,int x=0); |
| Answer» D. className(char c,int x=0); | |
| 152. |
Which constructor among the following will be called if a call is made like className(5,’a’);? |
| A. | className(int x=5,char c=’a’); |
| B. | int className(int x, char c, char d); |
| C. | className(int x, char c, int y); |
| D. | char className(char c,int x) |
| Answer» B. int className(int x, char c, char d); | |
| 153. |
If the constructors are overloaded by using the default arguments, which problem may arise? |
| A. | The constructors might have all the same arguments except the default arguments |
| B. | The constructors might have same return type |
| C. | The constructors might have same number of arguments |
| D. | The constructors can’t be overloaded with respect to default arguments |
| Answer» B. The constructors might have same return type | |
| 154. |
How many parameters must be passed if only the following prototype is given to a constructor? Prototype: className(int x, int y, int z=0); |
| A. | 1 |
| B. | 2 |
| C. | 3 |
| D. | Compile time error |
| Answer» C. 3 | |
| 155. |
Which is the correct syntax for using default arguments with the constructor? |
| A. | default constructorName(default int x=0) |
| B. | constructorName(default int x=0) |
| C. | constructorName(int x=0) |
| D. | constructorName() |
| Answer» D. constructorName() | |
| 156. |
Can a class have more than one function with all the default arguments? |
| A. | Yes, always |
| B. | Yes, if argument list is different |
| C. | No, because constructors overloading doesn’t depend on argument list |
| D. | No, never |
| Answer» E. | |
| 157. |
Which among the following can be used in place of default constructor? |
| A. | constructorName(int x,int y=0) |
| B. | constructorName(int x=0,int y=0) |
| C. | constructorName(int x=0,int y) |
| D. | constructorName(int x,int y) |
| Answer» C. constructorName(int x=0,int y) | |
| 158. |
The Constructors with all the default arguments are similar as default constructors. (True/False) |
| A. | True |
| B. | False |
| Answer» B. False | |
| 159. |
If a constructors should be capable of creating objects without argument and with arguments, which is a good alternative for this purpose? |
| A. | Use zero argument constructor |
| B. | Use constructor with one parameter |
| C. | Use constructor with all default arguments |
| D. | Use default constructor |
| Answer» D. Use default constructor | |
| 160. |
Which among the following is true for constructors overloading? |
| A. | Constructors can’t be overloaded |
| B. | Constructors can be overloaded using different signatures |
| C. | Constructors can be overloaded with same signatures |
| D. | Constructors can be overloaded with different return types |
| Answer» C. Constructors can be overloaded with same signatures | |
| 161. |
The virtual function overrides ____________ |
| A. | Do not acquire base class declaration of default arguments |
| B. | Do acquire base class declaration of default arguments |
| C. | Do not link with the default arguments of base class |
| D. | Do link with the default argument but only of derived classes |
| Answer» B. Do acquire base class declaration of default arguments | |
| 162. |
The default argument get bound during declaration ________________ |
| A. | The default argument get bound during declaration ________________ |
| B. | And are executed simultaneously |
| C. | But are executed only if priority is give |
| D. | But are executed during function call |
| Answer» E. | |
| 163. |
The names given to the default arguments are only looked up and ________________. And are bound during declaration. |
| A. | Checked for availability |
| B. | Checked for random access |
| C. | Checked for accessibility |
| D. | Checked for feasibility |
| Answer» D. Checked for feasibility | |
| 164. |
The using declaration _________ |
| A. | Doesn’t carry over the default values |
| B. | Carries over the known default arguments |
| C. | Carries over only the normal arguments |
| D. | Carries over only few default arguments |
| Answer» C. Carries over only the normal arguments | |
| 165. |
The non-template functions can be added with default arguments to already declared functions ____________________ |
| A. | If and only if the function is declared again in the same scope |
| B. | If and only if the function is declared only once in the same scope |
| C. | If and only if the function is declared in different scope |
| D. | If and only if the function is declared twice in the program |
| Answer» B. If and only if the function is declared only once in the same scope | |
| 166. |
Which among the following is false for default arguments? |
| A. | Those are not allowed with declaration of pointer to functions |
| B. | Those are not allowed with the reference to functions |
| C. | Those are not allowed with the typedef declarations |
| D. | Those are allowed with pointer and reference to function declaration |
| Answer» E. | |
| 167. |
Default arguments are _________________________ |
| A. | Only allowed in the parameter list of the function declaration |
| B. | Only allowed in the return type of the function declaration |
| C. | Only allowed with the class name definition |
| D. | Only allowed with the integer type values |
| Answer» B. Only allowed in the return type of the function declaration | |
| 168. |
Which among the following is wrong call to the function void test(int x, int y=0, int z=0)? |
| A. | test(5,6,7); |
| B. | test(5); |
| C. | test(); |
| D. | test(5,6); |
| Answer» D. test(5,6); | |
| 169. |
What function will be called with the independent syntax “test(5,6,7);”? |
| A. | void test(int x, int y) |
| B. | void test(int x=0,int y,int z) |
| C. | int test(int x=0,y=0,z=0) |
| D. | void test(int x,int y, int z=0) |
| Answer» E. | |
| 170. |
If a function have all the default arguments but still some values are passed to the function then ______________ |
| A. | The function will use the values passed to it |
| B. | The function will use the default values as those are local |
| C. | The function can use any value whichever is high |
| D. | The function will choose the minimum values |
| Answer» B. The function will use the default values as those are local | |
| 171. |
Which among the following function can be called without arguments? |
| A. | void add(int x, int y=0) |
| B. | void add(int=0) |
| C. | void add(int x=0, int y=0) |
| D. | void add(char c) |
| Answer» D. void add(char c) | |
| 172. |
If a member function have to be made both zero argument and parameterized constructor, which among the following can be the best option? |
| A. | Two normal and one default argument |
| B. | At least one default argument |
| C. | Exactly one default argument |
| D. | Make all the arguments default |
| Answer» E. | |
| 173. |
Which is correct condition for the default arguments? |
| A. | Those must be declared as last arguments in argument list |
| B. | Those must be declared first in the argument list |
| C. | Those can be defined anywhere in the argument list |
| D. | Those are declared inside the function definition |
| Answer» B. Those must be declared first in the argument list | |
| 174. |
What are default arguments? |
| A. | Arguments which are not mandatory to be passed |
| B. | Arguments with default value that aren’t mandatory to be passed |
| C. | Arguments which are not passed to functions |
| D. | Arguments which always take same data value |
| Answer» C. Arguments which are not passed to functions | |
| 175. |
Which is the correct syntax for declaring type of this in a member function? |
| A. | classType [cv-qualifier-list] *const this; |
| B. | classType const[cv-qualifier-list] *this; |
| C. | [cv-qualifier-list]*const classType this; |
| D. | [cv-qualifier-list] classType *const this; |
| Answer» E. | |
| 176. |
Which among the following is/are type(s) of this pointer? |
| A. | const |
| B. | volatile |
| C. | const or volatile |
| D. | int |
| Answer» D. int | |
| 177. |
This pointer can be used directly to ___________ |
| A. | To manipulate self-referential data structures |
| B. | To manipulate any reference to pointers to member functions |
| C. | To manipulate class references |
| D. | To manipulate and disable any use of pointers |
| Answer» B. To manipulate any reference to pointers to member functions | |
| 178. |
Earlier implementations of C++ ___________________ |
| A. | Never allowed assignment to this pointer |
| B. | Allowed no assignment to this pointer |
| C. | Allowed assignments to this pointer |
| D. | Never allowed assignment to any pointer |
| Answer» D. Never allowed assignment to any pointer | |
| 179. |
The this pointers ___________________ |
| A. | Are modifiable |
| B. | Can be assigned any value |
| C. | Are made variables |
| D. | Are non-modifiable |
| Answer» E. | |
| 180. |
Which syntax doesn’t execute/is false when executed? |
| A. | if(&object != this) |
| B. | if(&function !=object) |
| C. | this.if(!this) |
| D. | this.function(!this) |
| Answer» B. if(&function !=object) | |
| 181. |
The address of the object _________________ |
| A. | Can’t be accessed from inside the function |
| B. | Can’t be accessed in the program |
| C. | Is available inside the member function using this pointer |
| D. | Can be accessed using the object name inside the member function |
| Answer» D. Can be accessed using the object name inside the member function | |
| 182. |
Which is the correct interpretation of the member function call from an object, object.function(parameter); |
| A. | object.function(&this, parameter) |
| B. | object(&function,parameter) |
| C. | function(&object,¶meter) |
| D. | function(&object,parameter) |
| Answer» E. | |
| 183. |
The result of sizeof() function __________________ |
| A. | Includes space reserved for this pointer |
| B. | Includes space taken up by the address pointer by this pointer |
| C. | Doesn’t include the space taken by this pointer |
| D. | Doesn’t include space for any data member |
| Answer» D. Doesn’t include space for any data member | |
| 184. |
An object’s this pointer _____________________ |
| A. | Isn’t part of class |
| B. | Isn’t part of program |
| C. | Isn’t part of compiler |
| D. | Isn’t part of object itself |
| Answer» E. | |
| 185. |
The this pointer is accessible __________________ |
| A. | Within all the member functions of the class |
| B. | Only within functions returning void |
| C. | Only within non-static functions |
| D. | Within the member functions with zero arguments |
| Answer» D. Within the member functions with zero arguments | |
| 186. |
Which is the pointer which denotes the object calling the member function? |
| A. | Variable pointer |
| B. | This pointer |
| C. | Null pointer |
| D. | Zero pointer |
| Answer» C. Null pointer | |
| 187. |
References to object are same as pointers of object. |
| A. | True |
| B. | False |
| Answer» C. | |
| 188. |
What should be done to prevent changes that may be made to the values pointed by the pointer? |
| A. | Usual pointer can’t change the values pointed |
| B. | Pointer should be made virtual |
| C. | Pointer should be made anonymous |
| D. | Pointer should be made const |
| Answer» E. | |
| 189. |
How can the address stored in the pointer be retrieved? |
| A. | Using * symbol |
| B. | Using $ symbol |
| C. | Using & symbol |
| D. | Using @ symbol |
| Answer» D. Using @ symbol | |
| 190. |
If pointer to an object is created and the object gets deleted without using the pointer: |
| A. | It becomes void pointer |
| B. | It becomes dangling pointer |
| C. | It becomes null pointer |
| D. | It becomes zero pointer |
| Answer» C. It becomes null pointer | |
| 191. |
Which is the correct syntax to call a member function using pointer? |
| A. | pointer->function() |
| B. | pointer.function() |
| C. | pointer::function() |
| D. | pointer:function() |
| Answer» B. pointer.function() | |
| 192. |
Is name of an array of objects is also a pointer to object? |
| A. | Yes, always |
| B. | Yes, in few cases |
| C. | No, because it represents more than one object |
| D. | No, never |
| Answer» B. Yes, in few cases | |
| 193. |
Can pointers to object access the private members of the class? |
| A. | Yes, always |
| B. | Yes, only if it is only pointer to object |
| C. | No, because objects can be referenced from another objects too |
| D. | No, never |
| Answer» E. | |
| 194. |
Pointer to a base class can be initialized with the address of derived class, because of _______ |
| A. | derived-to-base implicit conversion for pointers |
| B. | base-to-derived implicit conversion for pointers |
| C. | base-to-base implicit conversion for pointers |
| D. | derived-to-derived implicit conversion for pointers |
| Answer» B. base-to-derived implicit conversion for pointers | |
| 195. |
A pointer _________________ |
| A. | Can point to only one object at a time |
| B. | Can point to more than one objects at a time |
| C. | Can point to only 2 objects at a time |
| D. | Can point to whole class objects at a time |
| Answer» B. Can point to more than one objects at a time | |
| 196. |
What is the size of object pointer? |
| A. | Equal to size of any usual pointer |
| B. | Equal to size of sum of all the members of object |
| C. | Equal to size of maximum sized member of object |
| D. | Equal to size of void |
| Answer» B. Equal to size of sum of all the members of object | |
| 197. |
If pointer to an object is declared, ___________ |
| A. | It can store any type of address |
| B. | It can store only void addresses |
| C. | It can only store address of integer type |
| D. | It can only store object address of class type specified |
| Answer» E. | |
| 198. |
How does compiler decide the intended object to be used, if more than one object are used? |
| A. | Using object name |
| B. | Using an integer pointer |
| C. | Using this pointer |
| D. | Using void pointer |
| Answer» D. Using void pointer | |
| 199. |
Which operator should be used to access the members of the class using object pointer? |
| A. | Dot operator |
| B. | Colon to the member |
| C. | Scope resolution operator |
| D. | Arrow operator |
| Answer» E. | |
| 200. |
Which is correct syntax for declaring pointer to object? |
| A. | className* objectName; |
| B. | className objectName; |
| C. | *className objectName; |
| D. | className objectName(); |
| Answer» B. className objectName; | |