Learn C++ MCQs
Prepare C++ MCQs (Multiple choice Questions) for exam and job interviews.
What will be the output of cout << (2 << 2) << endl;
1) 4
2) 8
3) 2
4) None of the above
Answer : 8
What is the output of cout << (5 || 0) << endl;
1) 1
2) 0
3) True
4) False
Answer : 1
Which of the following is a correct way to define a destructor in C++?
1) ~MyClass() {}
2) MyClass::~MyClass() {}
3) MyClass() ~ {}
4) None of the above
Answer : MyClass::~MyClass() {}
What is the output of cout << (3 & 4) << endl;
1) 0
2) 1
3) 3
4) 7
Answer : Option 1
Which of the following cannot be used as a function argument in C++?
1) int
2) float
3) char
4) None of the above
Answer : None of the above
What is the output of cout << (6 - 2 * 2) << endl;
1) 2
2) 4
3) 6
4) None of the above
Answer : 2
Which of the following is a correct way to define a nested class in C++?
1) class Outer { class Inner {}; };
2) class Outer { Inner class {}; };
3) class Outer::Inner {};
4) None of the above
Answer : class Outer { class Inner {}; };
What will be the output of cout << (10 / 2 * 3) << endl;
1) 15
2) 10
3) 5
4) None of the above
Answer : 15
Which of the following access specifiers allows access to members of a derived class?
1) public
2) private
3) protected
4) All of the above
Answer : protected
What is the output of cout << (4 == 4 && 2 < 5) << endl;
1) 1
2) 0
3) true
4) false
Answer : 1