C++ and OOP MCQ Test
61 C++ and OOP multiple-choice questions with answers, from the PGDCA syllabus. Instant score, full answer review, free and no signup.
Each attempt picks 25 questions at random from the 61 in this topic.
Score 50% or more? Get a certificate at 40% off
Finish any PGDCA test on this site with a score of 50% or above and you can claim a course certificate from Alien Institute of Computer at a 40% discount. Your score appears on the result screen with a WhatsApp button that carries it across for you.
Ask about the certificateAll 61 C++ and OOP questions with answers
1. C++ was originally known by which name?
- A. C with Classes
- B. Advanced C
- C. Object C
- D. New C
Answer: C with Classes
2. Which of these is NOT a feature of object-oriented programming?
- A. Encapsulation
- B. Inheritance
- C. Polymorphism
- D. Compilation
Answer: Compilation
3. What is a class in C++?
- A. A blueprint for creating objects
- B. A type of loop
- C. A memory address
- D. A built-in function
Answer: A blueprint for creating objects
4. What is an object in object-oriented programming?
- A. A copy of a function
- B. An instance of a class
- C. A data type
- D. A header file
Answer: An instance of a class
5. Which OOP concept hides internal data and exposes only what is needed?
- A. Inheritance
- B. Encapsulation
- C. Polymorphism
- D. Recursion
Answer: Encapsulation
6. Which OOP concept lets one class acquire the properties of another?
- A. Encapsulation
- B. Inheritance
- C. Abstraction
- D. Overloading
Answer: Inheritance
7. Which OOP concept means 'one name, many forms'?
- A. Inheritance
- B. Polymorphism
- C. Encapsulation
- D. Modularity
Answer: Polymorphism
8. Which OOP concept shows only essential features and hides the details?
- A. Abstraction
- B. Inheritance
- C. Overriding
- D. Linking
Answer: Abstraction
9. Which access specifier makes members accessible from anywhere?
- A. private
- B. protected
- C. public
- D. internal
Answer: public
10. What is the default access specifier for members of a C++ class?
- A. public
- B. private
- C. protected
- D. static
Answer: private
11. What is the default access specifier for members of a C++ struct?
- A. private
- B. public
- C. protected
- D. none
Answer: public
12. Which access specifier allows access in derived classes but not outside?
- A. public
- B. private
- C. protected
- D. friend
Answer: protected
13. What is a constructor in C++?
- A. A function that destroys an object
- B. A special member function called when an object is created
- C. A type of pointer
- D. A loop control statement
Answer: A special member function called when an object is created
14. What name must a constructor have?
- A. init
- B. main
- C. The same name as the class
- D. construct
Answer: The same name as the class
15. What does a constructor return?
- A. An integer
- B. A pointer to the object
- C. Nothing — it has no return type
- D. A boolean
Answer: Nothing — it has no return type
16. Which symbol prefixes a destructor name in C++?
- A. #
- B. ~
- C. !
- D. @
Answer: ~
17. When is a destructor called?
- A. When the object is created
- B. When the object goes out of scope or is deleted
- C. At program start
- D. Before every method call
Answer: When the object goes out of scope or is deleted
18. How many destructors can a class have?
- A. Only one
- B. Two
- C. As many as needed
- D. None
Answer: Only one
19. What is a copy constructor used for?
- A. To create an object from another object of the same class
- B. To delete an object
- C. To copy a file
- D. To convert data types
Answer: To create an object from another object of the same class
20. What is function overloading?
- A. Calling a function too many times
- B. Several functions with the same name but different parameters
- C. A function that calls itself
- D. A function with no return type
Answer: Several functions with the same name but different parameters
21. Which of these can NOT be used to distinguish overloaded functions?
- A. Number of parameters
- B. Types of parameters
- C. Return type alone
- D. Order of parameters
Answer: Return type alone
22. What is operator overloading?
- A. Using too many operators
- B. Giving an existing operator a new meaning for user-defined types
- C. Removing an operator
- D. Changing operator precedence
Answer: Giving an existing operator a new meaning for user-defined types
23. Which operator can NOT be overloaded in C++?
- A. +
- B. ==
- C. ::
- D. []
Answer: ::
24. Which keyword declares a function that can be redefined in a derived class?
- A. static
- B. virtual
- C. friend
- D. inline
Answer: virtual
25. What is function overriding?
- A. Two functions with the same name in one class
- B. A derived class redefining a base class function
- C. Calling a function repeatedly
- D. Deleting a function
Answer: A derived class redefining a base class function
26. What is a pure virtual function?
- A. A function with no parameters
- B. A virtual function declared with = 0 and no body in the base class
- C. A function that returns void
- D. A private function
Answer: A virtual function declared with = 0 and no body in the base class
27. A class containing at least one pure virtual function is called what?
- A. Final class
- B. Abstract class
- C. Static class
- D. Friend class
Answer: Abstract class
28. Can an abstract class be instantiated directly?
- A. Yes, always
- B. No, it cannot
- C. Only with new
- D. Only inside main()
Answer: No, it cannot
29. Which type of polymorphism is resolved at compile time?
- A. Run-time polymorphism
- B. Compile-time polymorphism
- C. Dynamic binding
- D. Late binding
Answer: Compile-time polymorphism
30. Virtual functions are an example of which kind of binding?
- A. Early binding
- B. Late (dynamic) binding
- C. Static binding
- D. No binding
Answer: Late (dynamic) binding
31. What is a friend function?
- A. A function inside another class
- B. A non-member function granted access to a class's private members
- C. A recursive function
- D. An overloaded function
Answer: A non-member function granted access to a class's private members
32. Which inheritance type has one derived class from one base class?
- A. Multiple
- B. Single
- C. Hierarchical
- D. Hybrid
Answer: Single
33. Which inheritance type has one class derived from more than one base class?
- A. Single
- B. Multiple
- C. Multilevel
- D. Hierarchical
Answer: Multiple
34. Which inheritance type has a chain such as A → B → C?
- A. Multiple
- B. Multilevel
- C. Hierarchical
- D. Hybrid
Answer: Multilevel
35. Which inheritance type has several classes derived from one base class?
- A. Multilevel
- B. Hierarchical
- C. Multiple
- D. Single
Answer: Hierarchical
36. Which C++ operator allocates memory dynamically?
- A. malloc
- B. new
- C. alloc
- D. create
Answer: new
37. Which C++ operator releases memory allocated with new?
- A. free
- B. delete
- C. remove
- D. release
Answer: delete
38. Which object is used for standard output in C++?
- A. cin
- B. cout
- C. cerr
- D. printf
Answer: cout
39. Which object is used for standard input in C++?
- A. cout
- B. cin
- C. clog
- D. scanf
Answer: cin
40. Which operator is used with cout to send data to output?
- A. >>
- B. <<
- C. ->
- D. ::
Answer: <<
41. Which operator is used with cin to read data?
- A. <<
- B. >>
- C. &&
- D. ::
Answer: >>
42. Which header is required for cin and cout?
- A. stdio.h
- B. iostream
- C. conio.h
- D. stdlib.h
Answer: iostream
43. What does 'using namespace std;' do?
- A. Imports a file
- B. Makes names from the std namespace available without the std:: prefix
- C. Creates a new namespace
- D. Starts the program
Answer: Makes names from the std namespace available without the std:: prefix
44. What is the scope resolution operator in C++?
- A. .
- B. ->
- C. ::
- D. :
Answer: ::
45. What is an inline function?
- A. A function written on one line
- B. A function whose code the compiler may substitute at the call site
- C. A function inside a loop
- D. A private function
Answer: A function whose code the compiler may substitute at the call site
46. Which keyword refers to the current object inside a member function?
- A. self
- B. this
- C. me
- D. current
Answer: this
47. What is a static data member of a class?
- A. A member unique to each object
- B. A member shared by all objects of the class
- C. A constant member
- D. A private member
Answer: A member shared by all objects of the class
48. What is a template in C++?
- A. A design pattern
- B. A way to write generic code that works with any data type
- C. A header file
- D. A class diagram
Answer: A way to write generic code that works with any data type
49. Which keyword introduces a template in C++?
- A. generic
- B. template
- C. typename only
- D. class only
Answer: template
50. Which block is used to handle an exception in C++?
- A. try
- B. catch
- C. throw
- D. final
Answer: catch
51. Which keyword raises an exception in C++?
- A. raise
- B. throw
- C. signal
- D. error
Answer: throw
52. What does STL stand for in C++?
- A. Standard Template Library
- B. System Type Library
- C. Structured Text Language
- D. Static Type Linker
Answer: Standard Template Library
53. Which STL container stores elements in a resizable array?
- A. list
- B. vector
- C. map
- D. set
Answer: vector
54. Which STL container stores unique key-value pairs?
- A. vector
- B. map
- C. stack
- D. queue
Answer: map
55. Which STL container follows Last In First Out order?
- A. queue
- B. stack
- C. vector
- D. deque
Answer: stack
56. Is C++ a purely object-oriented language?
- A. Yes, completely
- B. No — it also supports procedural programming
- C. Only in newer versions
- D. Only with templates
Answer: No — it also supports procedural programming
57. What is data hiding in OOP?
- A. Deleting data
- B. Restricting direct access to an object's internal data
- C. Encrypting data
- D. Compressing data
Answer: Restricting direct access to an object's internal data
58. What is a mutable member in C++?
- A. A member that cannot change
- B. A member that can be modified even in a const object
- C. A static member
- D. A pointer member
Answer: A member that can be modified even in a const object
59. Which comment style does C++ support that C89 did not?
- A. /* */
- B. //
- C. #
- D. <!-- -->
Answer: //
60. What is the size of an empty class object in C++ typically?
- A. 0 bytes
- B. 1 byte
- C. 4 bytes
- D. 8 bytes
Answer: 1 byte
61. Which of these is a valid C++ file extension?
- A. .c
- B. .cpp
- C. .cs
- D. .py
Answer: .cpp
Frequently asked questions
How many C++ and OOP questions are in this test?
This page has 61 C++ and OOP MCQs with answers. Each attempt picks 25 of them at random.
Is the C++ and OOP test free?
Yes — it is free, needs no signup, and you can retake it as many times as you like.
Can I get a certificate for this test?
Score 50% or more and you can claim a certificate from Alien Institute of Computer at 40% off. The WhatsApp button appears on your result screen.