C++ MCQ Questions

Our website offers a comprehensive collection of C++ MCQs to help learners practice and master core programming concepts. Topics covered include object-oriented programming, classes, inheritance, polymorphism, templates, exception handling, and more. Each question is designed to test understanding with clear explanations to support learning. Ideal for students, professionals, and interview aspirants, this platform makes C++ preparation easy, interactive, and effective for academic and job success.

Q1. Which of the following is not a feature of C++?

Correct Answer: B

C++ does not use platform-independent bytecode (that is Java).

Q2. Which of the following is used to define a class in C++?

Correct Answer: A

C++ classes are defined using the class keyword.

Q3. Which concept allows the use of the same function name with different parameter lists?

Correct Answer: D

Function overloading lets multiple functions share the same name but differ in parameters.

Q4. Which operator cannot be overloaded in C++?

Correct Answer: B

The scope resolution operator (::) cannot be overloaded in C++.

Q5. Which of the following is the correct syntax to declare a constructor?

Correct Answer: A

Constructors have the same name as the class and no return type.

Q6. Which feature of OOP in C++ provides data hiding?

Correct Answer: B

Encapsulation is used for data hiding by combining data and functions.

Q7. Which keyword is used to inherit a class in C++?

Correct Answer: C

C++ uses a colon (:) to define inheritance.

Q8. Which of the following supports runtime polymorphism in C++?

Correct Answer: B

Virtual functions enable runtime (dynamic) polymorphism in C++.

Q9. Which keyword is used to release dynamically allocated memory in C++?

Correct Answer: B

delete operator deallocates memory allocated with new.

Q10. Which of the following access specifiers is used by default in a class?

Correct Answer: A

By default, class members are private in C++.

Q11. Which function is called automatically when an object goes out of scope in C++?

Correct Answer: B

The destructor (~ClassName) is automatically invoked when an object is destroyed.

Q12. Which keyword is used to prevent a class from being inherited in C++11 and later?

Correct Answer: C

final keyword prevents further inheritance of a class.

Q13. What is the correct syntax of defining a namespace in C++?

Correct Answer: B

C++ namespaces are defined using the namespace keyword.

Q14. Which of the following is true about references in C++?

Correct Answer: A

References must always be initialized and cannot be reseated or NULL.

Q15. Which operator is used to resolve the scope in C++?

Correct Answer: B

The scope resolution operator (::) is used to specify namespace or class scope.

Q16. Which STL component provides a dynamic array in C++?

Correct Answer: C

std::vector is a dynamic array that can grow or shrink in size.

Q17. Which function is invoked when new memory allocation fails in C++?

Correct Answer: B

bad_alloc exception is thrown when new cannot allocate memory.

Q18. Which of the following is used to define a pure virtual function in C++?

Correct Answer: B

Pure virtual functions are declared with = 0.

Q19. Which of the following is the file extension of a C++ source file?

Correct Answer: B

C++ source files typically use the .cpp extension.

Q20. Which of the following is used for input and output in C++?

Correct Answer: B

C++ uses iostream for standard input and output.

Latest Blogs