Learn C++ MCQs
Prepare C++ MCQs (Multiple choice Questions) for exam and job interviews.
What is the output of cout << (true && false) << endl;
1) 1
2) 0
3) true
4) false
Answer : Option 2
Which of the following is used to define an inline function in C++?
1) inline
2) static
3) const
4) None of the above
Answer : inline
What is the output of cout << (2 | 3) << endl;
1) 3
2) 2
3) 1
4) None of the above
Answer : 3
Which of the following statements is used to terminate a loop in C++?
1) break
2) exit
3) return
4) stop
Answer : break
What is the output of cout << (3 + 5 > 8) << endl;
1) 1
2) 0
3) true
4) false
Answer : 1
Which of the following is the correct way to declare a multi-dimensional array in C++?
1) int arr[3][4];
2) int arr[4][3];
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2
What does the `this` pointer point to in C++?
1) The current object
2) The base class
3) The derived class
4) The previous object
Answer : The current object
Which of the following is a feature of C++?
1) Encapsulation
2) Multiple inheritance
3) Polymorphism
4) All of the above
Answer : All of the above
What is the output of cout << (5 == 5) << endl;
1) 1
2) 0
3) 5
4) None of the above
Answer : 1
What is the correct way to define a class in C++?
1) class MyClass {}
2) class MyClass()
3) class MyClass;
4) class MyClass:
Answer : class MyClass {}