Learn C++ MCQs

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

What is the output of cout << (9 / 3 + 2) << endl;

1) 5

2) 3

3) 4

4) None of the above

Answer : 5

Which of the following is a correct way to declare a reference in C++?

1) int &ref = var;

2) int ref & = var;

3) int & ref = &var;

4) None of the above

Answer : int &ref = var;

What is the output of cout << (1 ^ 0) << endl;

1) 1

2) 0

3) True

4) False

Answer : 1

Which of the following is used to declare an inline function in C++?

1) inline

2) static

3) extern

4) const

Answer : inline

What is the output of cout << (8 >> 2) << endl;

1) 4

2) 2

3) 1

4) None of the above

Answer : 2

Which of the following is a method for memory deallocation in C++?

1) delete

2) free

3) dealloc

4) Both 1 and 2

Answer : Both 1 and 2

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

1) 14

2) 10

3) 7

4) None of the above

Answer : 14

What is the correct way to define a typedef in C++?

1) typedef int Integer;

2) using Integer = int;

3) Both 1 and 2

4) None of the above

Answer : Both 1 and 2

Which of the following operators can be overloaded in C++?

1) All of the above

2) Arithmetic operators

3) Relational operators

4) Logical operators

Answer : All of the above

Which of the following is a correct way to create a thread in C++?

1) std::thread t(func);

2) thread t(func);

3) std::thread t = new thread(func);

4) None of the above

Answer : std::thread t(func);