Home / Engineering / CPP Programming MCQs / Page 5
CPP Programming MCQs | Page - 5
Dear candidates you will find MCQ questions of CPP Programming here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.
M
Q. 41) In C++, const qualifier can be applied to
1) Member functions of a class
2) Function arguments
3) To a class data member which is declared as static
4) Reference variables
M
Q. 42) 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]
M
Q. 43) Which of the following is true about new when compared with malloc:
1) new is an operator, malloc is a function
2) new calls constructor, malloc doesn’t
3) new returns appropriate pointer, malloc returns void * and pointer needs to typecast to appropriate type.
M
Q. 44) Predict the output?
#include <iostream>
using namespace std;
class Test
{
int x;
Test()
{
x = 5;
} };
int main()
{
Test *t = new Test;
cout << t->x;
}
M
Q. 45) Is it fine to call delete twice for a pointer?
#include<iostream>
using namespace std;
int main()
{
int *ptr = new int;
delete ptr;
delete ptr;
return 0;
}
M
Q. 46) When the inheritance is private, the private methods in base class are __________ in the derived class (in C++).
M
Q. 47) What happens when delete is used for a NULL pointer?
int *ptr = NULL;
delete ptr;
M
Q. 48) Which of the following is true about virtual functions in C++?
M
Q. 49) 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 an
instance of this class cannot be created.
M
Q. 50) What is the size of wchar_t in C++?
Explore More Categories
Click on category to learn MCQs of that category.Electronics and Communication Engineering