C++ Multiple Choice Questions
81. What is the implicit pointer that is passed as the first argument for nonstatic member functions?
a. ‘self’ pointer
b. std::auto_ptr pointer
c. ‘Myself’ pointer
d. ‘this’ pointer
82. Which of the following operators can be overloaded?
a. . (dot or member access operator)
b. & (address-of operator)
c. sizeof operator
d. ?: (conditional operator)
83. Which of the following operator cannot be overloaded?
#NAME?
b. == (equality operator)
c. –> (row operator)
d. :: (cope resolution operator)
84. Which of the following operators below allow to define the member functions of a class outside the class?
a. :: b. ? c. :? d. %
85. Which of the following is not a valid conditional inclusions in preprocessor directives
a. #ifdef
b. #ifundef
c. #endif
d. #elif
86. Which of the following is not a standard exception built in C++.
a. std::bad_creat
b. std::bad_alloc
c. std::bad_cast
d. std::bad_typeid
87. If a member needs to have unique value for all the objects of that same class, declare the member as
a. Global variable outside class
b. Local variable inside constructor
c. Static variable inside class
d. Dynamic variable inside class
88. Under which of the following circumstances, synchronization takes place?
a. When the file is closed
b. When the buffer is empty
c. Explicitly, with manipulators
d. both a and c
89. Which of the following functions below can be used Allocate space for array in memory?
a. calloc()
b. malloc()
c. Realloc()
d. both a and b
90. Which of the following is not a valid conditional inclusions in preprocessor directives
a. #ifdef
b. #ifundef
c. #endif
d. #elif
91. Value of a in a = (b = 5, b + 5); is
a. Junk value
b. Syntax error
c. 5
d. 10
92. Minimum number of temporary variable needed to swap the contents of 2 variables is:
a. 1
b. 2
c. 3
d. 0
94. There is nothing like a virtual constructor of a class.
a. False
b. True
95. C++ provides facility to specify that the compiler should match function calls with the correct definition at the run time. This process is called as
a. Static binding
b. Dynamic Binding
96. The output of this program is
int main () { cout << "Hello World!" return 0; }
a. Hello World
b. Syntax error
c. 0
d. Hello World!
97. The return value of the following code is
Class1& test(Class1 obj) { Class1 *ptr = new Class1(); ......... return ptr; }
a. object of Class1
b. reference to ptr
c. reference of Class1
d. object pointed by ptr
98. The output of
{
int a = 5;
int b = 10;
cout << (a>b?a:b);
}
a. 5
b. 10
c. Syntax error
d. None of above
99. The output of this program is
int a = 10; void main() { int a = 20; cout << a << ::a; }
a. Syntax error
b. 10 20
c. 20 10
d. 20 20
100. Observe following program and answer
class Example{ public: int a,b,c; Example(){a=b=c=1;} //Constructor 1 Example(int a){a = a; b = c = 1;} //Constructor 2 Example(int a,int b){a = a; b = b; c = 1;} //Constructor 3 Example(int a,int b,int c){ a = a; b = b; c = c;} //Constructor 4 }
In the above example of constructor overloading, the following statement will call which constructor
Example obj = new Example (1,2,3);
a. Constructor 2
b. Constructor 4
c. Constrcutor 1
d. Type mismatch error
Correct Answers to C++ MCQ Questions
81 – d | 82 – d | 83 – b | 84 – d | 85 – a | 86 – b | 87 – a | 88 – b | 89 – d | 90 – a |
91 – b | 92 – d | 93 – d | 94 – a | 95 – b | 96 – b | 97 – b | 98 – b | 99 – c | 100 – b |
Please, let us know if you discover any error or mistake in these MCQ sets. Don’t hesitate to leave your comments.
Download MCQ Questions PDF File for C++
Please visit Downloads section to download the pdf file of these MCQs from C++.
shradda says
Answer of question 84 is a not d.