On This Page

This set of CPP Programming Multiple Choice Questions & Answers (MCQs) focuses on Cpp Programming Set 2

Q1 | Which of the following is not a member of class?
Q2 | How can we restrict dynamic allocation of objects of a class using new?
Q3 | Which of the following operators cannot be overloaded?
Q4 | Which of the following operators are overloaded by default by the compiler in every user defined classes even if user has not written? 1) Comparison Operator (==) 2) Assignment Operator (=)
Q5 | Which of the following operators should be preferred to overload as a global function rather than a member method?
Q6 | How C++ compiler does differ between overloaded postfix and prefix operators?
Q7 | Which of the following operator functions cannot be global?
Q8 | Which of the following is true about this pointer?
Q9 | What is the use of this pointer?
Q10 | Which of the following in Object Oriented Programming is supported by Function overloading and default arguments features of C++?
Q11 | Output of the program?#includeusing namespace std;int fun(int x = 0, int y = 0, int z){ return (x + y + z); }int main(){cout << fun(10);return 0;}
Q12 | Output of following program?#include using namespace std;int fun(int=0, int = 0);int main(){cout << fun(5);return 0;}int fun(int x, int y){return (x+y);}
Q13 | Which of the following is true?
Q14 | If a function is friend of a class, which one of the following is wrong?
Q15 | Which one of the following is correct, when a class grants friend status to another class?
Q16 | 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
Q17 | 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]
Q18 | 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.
Q19 | Predict the output?#include using namespace std;class Test{int x;Test(){x = 5;} };int main(){Test *t = new Test;cout << t->x;}
Q20 | Is it fine to call delete twice for a pointer?#includeusing namespace std;int main(){int *ptr = new int;delete ptr;delete ptr;return 0;}
Q21 | When the inheritance is private, the private methods in base class are __________ in thederived class (in C++).
Q22 | What happens when delete is used for a NULL pointer?int *ptr = NULL;delete ptr;
Q23 | Which of the following is true about virtual functions in C++?
Q24 | 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.
Q25 | What is the size of wchar_t in C++?