Learn C++ MCQs

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

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

1) 13

2) 16

3) 8

4) 10

Answer : 13

Which of the following is a standard exception class in C++?

1) std::exception

2) std::runtime_error

3) std::logic_error

4) All of the above

Answer : All of the above

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

1) 1

2) 0

3) true

4) false

Answer : 1

Which keyword is used to define a constant in C++?

1) const

2) static

3) final

4) None of the above

Answer : const

Which of the following is the correct way to include a header file in C++?

1) #include <iostream>

2) #include "iostream"

3) Both 1 and 2

4) None of the above

Answer : Both 1 and 2

What is the output of cout << (10 == 10) << endl;

1) 1

2) 0

3) true

4) false

Answer : 1

Which of the following data structures is not part of the STL?

1) vector

2) map

3) deque

4) list

Answer : None of the above

What is the correct way to define an enum in C++?

1) enum Color { Red, Green, Blue };

2) enum { Red, Green, Blue } Color;

3) enum Color { Red, Green, Blue };

4) None of the above

Answer : enum Color { Red, Green, Blue };

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

1) <<

2) ++

3) =

4) ::

Answer : ::

What will be the output of cout << (8 % 5) << endl;

1) 3

2) 2

3) 1

4) None of the above

Answer : 3