

MCQOPTIONS
Saved Bookmarks
This section includes 53 Mcqs, each offering curated multiple-choice questions to sharpen your C++ Programming knowledge and support exam preparation. Choose a topic below to get started.
1. |
What is the technical word for the function defined in the following program? |
A. | Constructor |
B. | Destructor |
C. | Default Destructor |
D. | Function Template |
Answer» C. Default Destructor | |
2. |
Which of the following statement is correct about the program given below?
#include
|
A. | The program will print the output 0 0 . |
B. | The program will print the output 20 40 . |
C. | The program will print the output Garbage Garbage . |
D. | The program will report compile time error. |
Answer» C. The program will print the output Garbage Garbage . | |
3. |
What will be the output of the following program?
#include
|
A. | Base OK. Derived OK. |
B. | Base OK. Derived OK. Base DEL. |
C. | Base OK. Derived OK. Derived DEL. |
D. | Base OK. Derived OK. Derived DEL. Base DEL. |
Answer» E. | |
4. |
Which of the following statement is correct about the program given below?
#include
|
A. | The program will print the output 25 25 25 . |
B. | The program will print the output 25 Garbage 25 . |
C. | The program will print the output Garbage 25 25 . |
D. | The program will report compile time error. |
Answer» B. The program will print the output 25 Garbage 25 . | |
5. |
What will be the output of the following program?
#include
|
A. | 3 |
B. | 4 |
C. | 5 |
D. | Garbage-value |
Answer» C. 5 | |
6. |
What will be the output of the following program?
#include
|
A. | 6 6 4 |
B. | 6 6 5 |
C. | 5 40 38 |
D. | 6 40 38 |
Answer» E. | |
7. |
What will be the out of the following program?
#include
|
A. | 11 22 0 0 |
B. | 11 11 0 22 |
C. | 11 11 11 0 |
D. | 11 11 11 22 |
Answer» E. | |
8. |
Which of the following constructor is used in the program given below?
#include
|
A. | Copy constructor |
B. | Simple constructor |
C. | Non-parameterized constructor |
D. | Default constructor |
Answer» E. | |
9. |
What will be the output of the following program?
#include
|
A. | Base OK. Derived OK. |
B. | Base OK. Derived OK. Base DEL. |
C. | Base OK. Derived OK. Derived DEL. |
D. | Base OK. Derived OK. Derived DEL. Base DEL. |
Answer» C. Base OK. Derived OK. Derived DEL. | |
10. |
What is the technical word for the function ~IndiaBix() defined in the following program?
#include
|
A. | Constructor |
B. | Destructor |
C. | Default Destructor |
D. | Function Template |
Answer» C. Default Destructor | |
11. |
What will be the out of the following program?
#include
|
A. | 11 22 0 0 |
B. | 11 0 0 22 |
C. | 11 0 22 0 |
D. | 11 22 11 22 |
Answer» D. 11 22 11 22 | |
12. |
Which of the following statement is correct about the program given below?
#include
|
A. | The program will print the output Short . |
B. | The program will print the output Int . |
C. | The program will print the output Float . |
D. | The program will print the output Final . |
Answer» C. The program will print the output Float . | |
13. |
What will be the output of the following program?
#include
|
A. | Base OK. Derived OK. Derived DEL. |
B. | Base OK. Base OK. Derived OK. Derived DEL. |
C. | Base OK. Derived OK. Derived DEL. Derived DEL. |
D. | Base OK. Base OK. Derived OK. Derived DEL. Derived DEL. |
Answer» E. | |
14. |
A union that has no constructor can be initialized with another union of __________ type. |
A. | different |
B. | same |
C. | virtual |
D. | class |
Answer» C. virtual | |
15. |
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» C. When the control comes out of the function in which they are being used. | |
16. |
Which of the following statement is correct about the program given below?
#include
|
A. | The program will print the output 76. |
B. | The program will print the output 108. |
C. | The program will print the output garbage value. |
D. | The program will report compile time error. |
Answer» B. The program will print the output 108. | |
17. |
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» D. only pass by address | |
18. |
A destructor takes __________ arguments. |
A. | one |
B. | two |
C. | three |
D. | no |
Answer» E. | |
19. |
If the programmer does not explicitly provide a destructor, then which of the following creates an empty destructor? |
A. | Preprocessor |
B. | Compiler |
C. | Linker |
D. | main() function |
Answer» C. Linker | |
20. |
Which of the following statement is correct about constructors? |
A. | A constructor has a return type. |
B. | A constructor cannot contain a function call. |
C. | A constructor has no return type. |
D. | A constructor has a void return type. |
Answer» D. A constructor has a void return type. | |
21. |
Which of the following statement is correct about the program given below?
#include
|
A. | The program will print the output 5. |
B. | The program will print the output Garbage-value. |
C. | The program will report compile time error. |
D. | The program will report runtime error. |
Answer» B. The program will print the output Garbage-value. | |
22. |
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» B. Forward order | |
23. |
Which of the following never requires any arguments? |
A. | Member function |
B. | Friend function |
C. | Default constructor |
D. | const function |
Answer» D. const function | |
24. |
Which of the following gets called when an object goes out of scope? |
A. | constructor |
B. | destructor |
C. | main |
D. | virtual function |
Answer» C. main | |
25. |
To ensure that every object in the array receives a destructor call, always delete memory allocated as an array with operator __________ . |
A. | destructor |
B. | delete |
C. | delete[] |
D. | kill[] |
Answer» D. kill[] | |
26. |
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» E. | |
27. |
Destructors __________ for automatic objects if the program terminates with a call to function exit or function abort. |
A. | are called |
B. | are inherited |
C. | are not called |
D. | are created |
Answer» D. are created | |
28. |
What will be the output of the following program?
#include
|
A. | 1234 |
B. | 4321 |
C. | 12344321 |
D. | 12341234 |
Answer» D. 12341234 | |
29. |
What will be the out of the following program?
#include
|
A. | 0 |
B. | 100 |
C. | 200 |
D. | 400 |
Answer» D. 400 | |
30. |
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» D. call zero-argument constructor | |
31. |
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» B. copy constructor | |
32. |
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» D. None of the above. | |
33. |
Which of the following cannot be declared as virtual? |
A. | Constructor |
B. | Destructor |
C. | Data Members |
D. | Both A and C |
Answer» E. | |
34. |
Which of the following statement is correct about the program given below?
#include
|
A. | The program will print the output Short . |
B. | The program will print the output Int . |
C. | The program will print the output Char . |
D. | The program will print the output Final . |
Answer» D. The program will print the output Final . | |
35. |
How many default constructors per class are possible? |
A. | Only one |
B. | Two |
C. | Three |
D. | Unlimited |
Answer» B. Two | |
36. |
__________ 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» C. destructor | |
37. |
Which of the following implicitly creates a default constructor when the programmer does not explicitly define at least one constructor for a class? |
A. | Preprocessor |
B. | Linker |
C. | Loader |
D. | Compiler |
Answer» E. | |
38. |
Which of the following statement is correct about destructors? |
A. | A destructor has void return type. |
B. | A destructor has integer return type. |
C. | A destructor has no return type. |
D. | A destructors return type is always same as that of main(). |
Answer» D. A destructors return type is always same as that of main(). | |
39. |
Which of the following statement is correct about the program given below?
#include
|
A. | The program will print the output 25. |
B. | The program will print the output Garbage-value. |
C. | The program will report compile time error. |
D. | The program will report runtime error. |
Answer» D. The program will report runtime error. | |
40. |
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» B. Twice | |
41. |
Which of the following statement is correct about the program given below?
#include
|
A. | The program will print the output India. |
B. | The program will print the output Bix. |
C. | The program will print the output IndiaBix. |
D. | The program will report compile time error. |
Answer» D. The program will report compile time error. | |
42. |
Constructors __________ to allow different approaches of object construction. |
A. | cannot overloaded |
B. | can be overloaded |
C. | can be called |
D. | can be nested |
Answer» C. can be called | |
43. |
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» B. Preprocessing error. | |
44. |
Which of the following gets called when an object is being created? |
A. | constructor |
B. | virtual function |
C. | destructor |
D. | main |
Answer» B. virtual function | |
45. |
Can a class have virtual destructor? |
A. | Yes |
B. | No |
Answer» B. No | |
46. |
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» C. function | |
47. |
What will be the output of the following program?
#include
|
A. | 99 |
B. | ASCII value of 99 |
C. | Garbage value |
D. | 99.5 |
Answer» C. Garbage value | |
48. |
A class's __________ is called when an object is destroyed. |
A. | constructor |
B. | destructor |
C. | assignment function |
D. | copy constructor |
Answer» C. assignment function | |
49. |
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» E. | |
50. |
It is a __________ error to pass arguments to a destructor. |
A. | logical |
B. | virtual |
C. | syntax |
D. | linker |
Answer» D. linker | |