Click “Download PDF”, then choose “Save as PDF” as the printer.
MCQs with answers
1. Which header must you include to use cout and cin?
2. Which of these is a valid variable name in C++?
3. Which loop always runs its body at least once, even when the condition is false from the start?
4. The vector of int named v holds 40, 10, 30, 20 in that order. After sort(v.begin(), v.end()), what is v[1]?
5. After the statements int x = 7; x += 3; x *= x; x %= 7; what is x?
6. int n = 2; switch (n) { case 1: cout << "A"; case 2: cout << "B"; case 3: cout << "C"; break; default: cout << "D"; } What is printed?
7. A function is defined as void doubleIt(int& a) { a = a * 2; }. In main, int n = 4; and then doubleIt(n); is called twice. What is n?
8. A class Account has only one constructor, Account(string name, double opening). Which line fails to compile?
9. Two vectors of int are created: a(3, 7) with parentheses and b{3, 7} with braces. Which statement is true?
10. Shape has a pure virtual function area(). The class Square derives from Shape but does not override area(). What happens if main tries to create a Square object?
© 2026 VJ Classes · vjclasses.in