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++?
A. Object-oriented programming
B. Platform-independent bytecode
C. Function overloading
D. Operator overloading
📘 View Explanation
Q2. Which of the following is used to define a class in C++?
A. class
B. struct
C. object
D. define
📘 View Explanation
Q3. Which concept allows the use of the same function name with different parameter lists?
A. Encapsulation
B. Inheritance
C. Polymorphism
D. Function overloading
📘 View Explanation
Q5. Which of the following is the correct syntax to declare a constructor?
A. ClassName()
B. void ClassName()
C. int constructor()
D. constructor()
📘 View Explanation
Q6. Which feature of OOP in C++ provides data hiding?
A. Abstraction
B. Encapsulation
C. Inheritance
D. Polymorphism
📘 View Explanation
Q7. Which keyword is used to inherit a class in C++?
A. inherits
B. extends
C. :
D. super
📘 View Explanation
Q8. Which of the following supports runtime polymorphism in C++?
A. Constructor overloading
B. Virtual functions
C. Function overloading
D. Friend functions
📘 View Explanation
Q9. Which keyword is used to release dynamically allocated memory in C++?
A. free
B. delete
C. remove
D. destroy
📘 View Explanation
Q10. Which of the following access specifiers is used by default in a class?
A. private
B. public
C. protected
D. internal
📘 View Explanation
Q11. Which function is called automatically when an object goes out of scope in C++?
A. constructor
B. destructor
C. finalize
D. free
📘 View Explanation
Q12. Which keyword is used to prevent a class from being inherited in C++11 and later?
A. static
B. sealed
C. final
D. const
📘 View Explanation
Q13. What is the correct syntax of defining a namespace in C++?
A. package MyNS {}
B. namespace MyNS { }
C. module MyNS {}
D. define namespace MyNS {}
📘 View Explanation
Q14. Which of the following is true about references in C++?
A. A reference must always be initialized
B. A reference can be NULL
C. A reference can be reseated
D. References are optional in C++
📘 View Explanation
Q15. Which operator is used to resolve the scope in C++?
A. :
B. ::
C. .
D. ->
📘 View Explanation
Q16. Which STL component provides a dynamic array in C++?
A. list
B. map
C. vector
D. queue
📘 View Explanation
Q17. Which function is invoked when new memory allocation fails in C++?
A. terminate()
B. bad_alloc()
C. new_fail()
D. malloc_error()
📘 View Explanation
Q18. Which of the following is used to define a pure virtual function in C++?
A. virtual void f();
B. virtual void f() = 0;
C. abstract void f();
D. virtual pure f();
📘 View Explanation
Q19. Which of the following is the file extension of a C++ source file?
A. .c
B. .cpp
C. .cs
D. .cp
📘 View Explanation
Q20. Which of the following is used for input and output in C++?
A. stdio.h
B. iostream
C. stdlib.h
D. fstream.h
📘 View Explanation