Which C++ data type can hold only the values true and false?
Correct answer D. bool
Topic / 30 questions
C++ MCQs test your understanding of the C++ language, including classes, constructors, pointers, inheritance and exception handling. They help computer science students and software job applicants check their basics, and every question shows its correct answer immediately so you can fix gaps before an exam or interview.
Correct answer D. bool
Correct answer D. Templates
Correct answer B. vector
Correct answer C. this
Correct answer D. public
Correct answer B. friend
Correct answer C. Function overloading
Correct answer B. protected
Correct answer B. By writing = 0 at the end of its declaration
Correct answer A. virtual
Correct answer B. Destructor
Correct answer A. ::
Correct answer C. <<
Correct answer C. delete
Correct answer B. iostream
Correct answer C. throw
Correct answer D. <fstream>
Correct answer A. Run Time
Correct answer B. Private
Correct answer B. Inheritance
This topic covers object-oriented C++ concepts that written tests often check. Questions ask which keywords generate and handle exceptions, namely try, throw and catch, and how code reusability is achieved through inheritance. You will see that a default constructor takes no arguments, that class members are private by default unlike struct members, and that an uninitialised pointer is called a wild pointer. Other items deal with declaring a pointer more than once and basic syntax rules. These points come up in computer science lecturer tests, software house screening tests and placement rounds.
Pakistan
India
Bangladesh
Members of a class in C++ are private by default, so they cannot be accessed from outside the class unless declared public or protected. In a struct, members are public by default. This difference is one of the most common C++ MCQ topics.
A wild pointer is a pointer that has been declared but not initialised, so it holds an unpredictable address. Using it can crash a program or corrupt memory. Good practice is to initialise pointers to nullptr or to a valid address when they are declared.
Last reviewed October 2026