A
Here, you will find a collection of MCQ questions on C++. Go through these questions to enhance your preparation for upcoming examinations and interviews.
To check the correct answer, simply click the View Answer button provided for each question.
Have your own questions to contribute? Click the button below to share your MCQs with others!
+ Add QuestionA
A
A
A
A
#include<iostream>
using namespace std;
class MyClass
{
static int a;
int b;
};
int MyClass::a;
int main()
{
cout << sizeof(MyClass);
return 0;
}
A
#include <iostream>
using namespace std;
class MyClass
{
int var;
public:
int write(int i) const {
var = i;
}
int read() const {
return var;
}
};
int main(int argc, char const *argv[])
{
MyClass obj;
obj.write(2);
cout << obj.read();
}
A
#include <iostream>
using namespace std;
class calculate {
int x, y;
public:
void val(int, int);
int sum() {
return (x + y);
}
};
void calculate::val(int a, int b) {
x = a;
y = b;
}
int main() {
calculate calculate;
calculate.val(5, 10);
cout << "The sum = " << calculate.sum();
return 0;
}
A
A
A
class A
{
public:
static int val;
}
If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.
Share Your MCQ