CPP Programming MCQs | Page - 2
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. Output of following C++ program?
#include<iostream>
using namespace std;
int main()
{
int x = 10;
int& ref = x;
ref = 20;
cout << "x = " << x << endl ;
x = 30;
cout << "ref = " << ref << endl;
return 0;
}
M
Q. What is the difference between struct and class in C++?
M
Q. Predict the output of following C++ program.
#include<iostream>
using namespace std;
class Empty {};
int main() {
cout << sizeof(Empty);
return 0;
}
M
Q. class Test {
int x;
};
int main() {
Test t;
cout << t.x;
return 0;
}
M
Q. A member function can always access the data in __________, (in C++).
M
Q. Which of the following is not correct for virtual function in C++?
M
Q. Which of the following is not correct (in C++)?
1. Class templates and function templates are instantiated in the same way
2. Class templates differ from function templates in the way they are initiated
3. Class template is initiated by defining an object using the template argument
4. Class templates are generally used for storage classes
M
Q. Which of the following cannot be passed to a function in C++?
M
Q. Which of the following, in C++, is inherited in a derived class from base class?
Jump to