Learn C++ MCQs

Prepare C++ MCQs (Multiple choice Questions) for exam and job interviews.

Which of the following is not a part of the C++ Standard Template Library (STL)?

1) list

2) map

3) set

4) None of the above

Answer : Option 4

What will be the output of cout << (true && false || true) << endl;

1) 1

2) 0

3) true

4) false

Answer : Option 1

Which of the following is used to declare a friend function in C++?

1) friend void func();

2) void friend func();

3) friend func();

4) None of the above

Answer : Option 1

Which of the following is a valid way to initialize an array in C++?

1) int arr[3] = {1, 2, 3};

2) int arr[] = {1, 2, 3};

3) Both 1 and 2

4) None of the above

Answer : Option 3

What will be the output of cout << (2 + 2 * 2) << endl;

1) 6

2) 8

3) 4

4) None of the above

Answer : Option 1

Which of the following statements is true about C++?

1) C++ is a low-level language.

2) C++ is a high-level language.

3) C++ does not support object-oriented programming.

4) None of the above

Answer : Option 2

What is the output of cout << (true + 1) << endl;

1) 1

2) 2

3) 0

4) None of the above

Answer : Option 2

Which of the following is the correct way to define a default constructor in C++?

1) MyClass() {}

2) MyClass(int x) {}

3) void MyClass() {}

4) None of the above

Answer : Option 1

What is the correct way to create a constant variable in C++?

1) const int x = 5;

2) int const x = 5;

3) Both 1 and 2

4) None of the above

Answer : Option 3

What is the output of cout << (3 * (4 + 5)) << endl;

1) 27

2) 27

3) 9

4) None of the above

Answer : Option 1