

MCQOPTIONS
Saved Bookmarks
This section includes 16 Mcqs, each offering curated multiple-choice questions to sharpen your Object Oriented Programming knowledge and support exam preparation. Choose a topic below to get started.
1. |
Which is a good alternative instead of having one zero argument constructor and one single argument constructor with default argument? |
A. | No constructor defined |
B. | One default value constructor |
C. | Defining the default constructor |
D. | Using one constructor with two arguments |
Answer» C. Defining the default constructor | |
2. |
Which is the correct statement for default constructors? |
A. | The constructors with all the default arguments |
B. | The constructors with all the null and zero values |
C. | The constructors which can’t be defined by programmer |
D. | The constructors with zero arguments |
Answer» E. | |
3. |
If there is a constructor with all the default arguments and arguments are not passed then _________________ |
A. | The default values given will not be used |
B. | Then all the null values will be used |
C. | Then all the default values given will be used |
D. | Then compiler will produce an error |
Answer» D. Then compiler will produce an error | |
4. |
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. | ;c) className(int x=0,char c); |
D. | className(char c,int x=0); |
Answer» D. className(char c,int x=0); | |
5. |
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. | ;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); | |
6. |
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 | |
7. |
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 | |
8. |
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() | |
9. |
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. | |
10. |
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) | |
11. |
The Constructors with all the default arguments are similar as default constructors. |
A. | True |
B. | False |
Answer» B. False | |
12. |
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 | |
13. |
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 | |
14. |
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); | |
15. |
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); | |
16. |
How many parameters must be passed if only the following prototype is given to a constructor? |
A. | ; |
B. | 1 |
C. | 2 |
D. | 3 |
Answer» C. 2 | |