

MCQOPTIONS
Saved Bookmarks
This section includes 24 Mcqs, each offering curated multiple-choice questions to sharpen your Computer Science Engineering (CSE) knowledge and support exam preparation. Choose a topic below to get started.
1. |
When an ADT is implemented as a C++ class, which of the following should normally be true? |
A. | Member functions are private, member variables are public |
B. | Member functions are public, member variables are private |
C. | Member functions as well as member variables are private |
D. | Member functions as well as member variables are public |
Answer» C. Member functions as well as member variables are private | |
2. |
Which of the followings is/are automatically added to every class, if we do not write our own? |
A. | Copy Constructor |
B. | Assignment Operator |
C. | A constructor without any parameter |
D. | All of the above |
Answer» E. | |
3. |
#include
|
A. | Compiler Error |
B. | Constructor called Constructor called |
C. | Constructor called |
D. | None of the above |
Answer» D. None of the above | |
4. |
Output of following program?#include
|
A. | Compiler Error |
B. | Runtime Error |
C. | Constructor called |
D. | None of the above |
Answer» B. Runtime Error | |
5. |
Which of the following is true about constructors?1) They cannot be virtual.2) They cannot be private.3) They are automatically called by new operator. |
A. | All 1, 2, and 3 |
B. | Only 1 and 3 |
C. | Only 1 and 2 |
D. | Only 2 and 3 |
Answer» C. Only 1 and 2 | |
6. |
Output of following C++ program?#include
|
A. | x = 20; ref = 30 |
B. | x = 20; ref = 20 |
C. | x = 10; ref = 30 |
D. | x = 30; ref = 30 |
Answer» B. x = 20; ref = 20 | |
7. |
Which of the following is true about templates?1) Template is a feature of C++ that allows us to write one code for different data types.2) We can write one function that can be used for all data types including user defined types. Like sort(), max(), min(), ..etc.3) We can write one class or struct that can be used for all data types including user defined types. Like Linked List, Stack, Queue,..etc.4) Template is an example of compile time polymorphism. |
A. | 1 and 2 |
B. | 1, 2 and 3 |
C. | 1, 2 and 4 |
D. | 1, 2, 3 and 4 |
Answer» E. | |
8. |
Which of the following is incorrect in C++?(1)When we write overloaded function we must code the function for each usage.(2)When we write function template we code the function only once.(3)It is difficult to debug macros(4)Templates are more efficient than macros |
A. | (1) and (2) |
B. | (1), (2) and (3) |
C. | (3) and (4) |
D. | All are correct. |
Answer» E. | |
9. |
Which of the following are member dereferencing operators in CPP? 1. * 2. :: 3. ->* 4. ::* 5. -> |
A. | Only 1, 3, 4 |
B. | Only 1 and 5 |
C. | Only 3 and 4 |
D. | Only 3,4,5 |
Answer» B. Only 1 and 5 | |
10. |
How to create a dynamic array of pointers (to integers) of size 10 using new in C++? Hint: We can create a non-dynamic array using int *arr[10] |
A. | int *arr = new int *[10]; |
B. | int **arr = new int *[10]; |
C. | int *arr = new int [10]; |
D. | Not Possible |
Answer» C. int *arr = new int [10]; | |
11. |
What happens when delete is used for a NULL pointer?int *ptr = NULL;delete ptr; |
A. | Compiler Error |
B. | Run-time Crash |
C. | No Error |
D. | None |
Answer» D. None | |
12. |
Output of following program?#include
|
A. | Compiler Error |
B. | 5 |
C. | 0 |
D. | 10 |
Answer» C. 0 | |
13. |
The code of statements which may cause abnormal termination of the program should be written under_________ block. |
A. | Try |
B. | catch |
C. | Finally |
D. | None of these |
Answer» B. catch | |
14. |
Output of the program?#include
|
A. | 10 |
B. | 0 |
C. | 20 |
D. | Compiler Error |
Answer» E. | |
15. |
Predict the output?#include
|
A. | Compiler Error |
B. | 5 |
C. | Garbage Value |
D. | 0 |
Answer» B. 5 | |
16. |
Is it fine to call delete twice for a pointer?#include
|
A. | Yes |
B. | No |
C. | none |
D. | all |
Answer» C. none | |
17. |
In C++, const qualifier can be applied to1) Member functions of a class2) Function arguments3) To a class data member which is declared as static4) Reference variables |
A. | Only 1, 2 and 3 |
B. | Only 1, 2 and 4 |
C. | All |
D. | Only 1, 3 and 4 |
Answer» D. Only 1, 3 and 4 | |
18. |
Which of the following is true about new when compared with malloc:1) new is an operator, malloc is a function2) new calls constructor, malloc doesn t3) new returns appropriate pointer, malloc returns void * and pointer needs to typecast to appropriate type. |
A. | 1 and 3 |
B. | 2 and 3 |
C. | 1 and 2 |
D. | All 1, 2 and 3 |
Answer» E. | |
19. |
Which of the following is true about pure virtual functions?1) Their implementation is not provided in a class where they are declared.2) If a class has a pure virtual function, then the class becomes abstract class and aninstance of this class cannot be created. |
A. | Both 1 and 2 |
B. | Only 1 |
C. | Only 2 |
D. | Neither 1 nor 2 |
Answer» D. Neither 1 nor 2 | |
20. |
When the inheritance is private, the private methods in base class are __________ in the derived class (in C++). |
A. | inaccessible |
B. | accessible |
C. | protected |
D. | public |
Answer» B. accessible | |
21. |
class Test {int x;};int main() {Test t;cout << t.x;return 0;} |
A. | 0 |
B. | Garbage Value |
C. | Compiler Error |
D. | None |
Answer» D. None | |
22. |
Predict the output of following C++ program.#include
|
A. | A non-zero value |
B. | 0 |
C. | Compiler Error |
D. | Runtime Error |
Answer» B. 0 | |
23. |
Which of the following is not correct (in C++)?1. Class templates and function templates are instantiated in the same way2. Class templates differ from function templates in the way they are initiated3. Class template is initiated by defining an object using the template argument4. Class templates are generally used for storage classes |
A. | (1) |
B. | (2), (4) |
C. | (2), (3), (4) |
D. | (4) |
Answer» D. (4) | |
24. |
When a method in a subclass has the same name and type signatures as a method in the superclass, then the method in the subclass _____ the method in the superclass. |
A. | Overloads |
B. | Friendships |
C. | Inherits |
D. | Overrides |
Answer» E. | |