{"id":720158,"date":"2024-06-01T17:56:50","date_gmt":"2024-06-01T12:26:50","guid":{"rendered":"https:\/\/infinitylearn.com\/surge\/?p=720158"},"modified":"2025-05-15T11:42:22","modified_gmt":"2025-05-15T06:12:22","slug":"c-mcq-questions-and-answers","status":"publish","type":"post","link":"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/","title":{"rendered":"C++ MCQ Questions and Answers"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_37 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" style=\"display: none;\"><label for=\"item\" aria-label=\"Table of Content\"><span style=\"display: flex;align-items: center;width: 35px;height: 30px;justify-content: center;\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/label><input type=\"checkbox\" id=\"item\"><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1' style='display:block'><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/#What_is_C\" title=\"What is C++?\">What is C++?<\/a><ul class='ez-toc-list-level-3'><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/#Variables_in_C\" title=\"Variables in C++\">Variables in C++<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/#Classes_and_Objects_in_C\" title=\"Classes and Objects in C++\">Classes and Objects in C++<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/#50_C_MCQ_Questions_and_Answers\" title=\"50 C++ MCQ Questions and Answers\">50 C++ MCQ Questions and Answers<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/#FAQs_on_C\" title=\"FAQs on C++\">FAQs on C++<\/a><ul class='ez-toc-list-level-3'><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/#What_is_the_advantage_of_C\" title=\"What is the advantage of C++?\">What is the advantage of C++?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/#Is_C_very_useful\" title=\"Is C++ very useful?\">Is C++ very useful?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/#What_is_OOPS_in_C\" title=\"What is OOPS in C++?\">What is OOPS in C++?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/#Who_invented_C\" title=\"Who invented C++?\">Who invented C++?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/#What_is_the_basic_concept_of_C\" title=\"What is the basic concept of C++?\">What is the basic concept of C++?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"What_is_C\"><\/span>What is C++?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>C++ is a programming language that allows developers to create software applications. It is an extension of the C programming language and is known for its efficiency and flexibility. C++ is used to build a wide range of applications, from operating systems to video games, and is considered one of the most powerful and versatile programming languages.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Variables_in_C\"><\/span>Variables in C++<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Variables are like containers that store information in a program. They have a name and a type, like &#8220;age&#8221; (integer) or &#8220;name&#8221; (string). You can store different values in variables and use them throughout your code. Variables make it easy to work with data and change it as needed.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Classes_and_Objects_in_C\"><\/span>Classes and Objects in C++<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Classes are like blueprints that define the properties and behaviors of an object. They contain variables (properties) and functions (behaviors). Objects are instances of a class, like a specific car or person. Objects have their own values for the properties defined in the class. Classes and objects help organize code and make it easier to work with complex data.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"50_C_MCQ_Questions_and_Answers\"><\/span>50 C++ MCQ Questions and Answers<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Here are 50 C++ MCQ questions for placement with answer. Prepare with these C++ MCQ to get ready for placement or exam, and manage time effectively. It also helps you find out where you need more practice.<\/p>\n<p><strong>1. What does the acronym &#8220;C++&#8221; stand for?<\/strong><\/p>\n<ul>\n<li>A) Common Computer Programming<\/li>\n<li>B) Central Computing Platform<\/li>\n<li>C) C Plus Plus<\/li>\n<li>D) Complete Coding Program<\/li>\n<\/ul>\n<p><strong>Answer: <\/strong>C) C Plus Plus<\/p>\n<p><strong>2.Which of the following is the correct syntax for a single-line comment in C++?<\/strong><\/p>\n<ul>\n<li>A) \/\/ This is a comment<\/li>\n<li>B) \/* This is a comment *\/<\/li>\n<li>C) # This is a comment<\/li>\n<li>D) &#8212; This is a comment<\/li>\n<\/ul>\n<p><strong>Answer: <\/strong>A) \/\/ This is a comment<\/p>\n<p><strong>3. What is the output of the following code snippet?<\/strong><\/p>\n<p>int x = 5;<br \/>\ncout &lt;&lt; &#8220;The value of x is: &#8221; &lt;&lt; x++ &lt;&lt; endl;<\/p>\n<ul>\n<li>A) The value of x is: 5<\/li>\n<li>B) The value of x is: 6<\/li>\n<li>C) The value of x is: 4<\/li>\n<li>D) None of the above<\/li>\n<\/ul>\n<p><strong>4. Which operator is used for dynamic memory allocation in C++?<\/strong><\/p>\n<ul>\n<li>A) new<\/li>\n<li>B) malloc<\/li>\n<li>C) allocate<\/li>\n<li>D) create<\/li>\n<\/ul>\n<p><strong>Answer: <\/strong>A) new<\/p>\n<p><strong>5. What is the output of the following code snippet?<\/strong><\/p>\n<p>int x = 10;<br \/>\nint y = x &lt;&lt; 1;<br \/>\ncout &lt;&lt; &#8220;Value of y: &#8221; &lt;&lt; y &lt;&lt; endl;<\/p>\n<ul>\n<li>A) Value of y: 5<\/li>\n<li>B) Value of y: 20<\/li>\n<li>C) Value of y: 2<\/li>\n<li>D) Value of y: 10<\/li>\n<\/ul>\n<p><strong>Answer:<\/strong> B) Value of y: 20<\/p>\n<p><strong>6. What is the correct syntax to declare a pointer in C++?<\/strong><\/p>\n<ul>\n<li>A) int pointer p;<\/li>\n<li>B) pointer int p;<\/li>\n<li>C) int *p;<\/li>\n<li>D) p = new int;<\/li>\n<\/ul>\n<p><strong><em>Answer: <\/em><\/strong><em>C) int p;<\/em><\/p>\n<p><strong>7. What does the keyword &#8220;const&#8221; indicate in C++?<\/strong><\/p>\n<ul>\n<li>A) It signifies a constant variable that cannot be modified.<\/li>\n<li>B) It specifies a function that returns a constant value.<\/li>\n<li>C) It denotes a variable that is constant throughout the program.<\/li>\n<li>D) All of the above<\/li>\n<\/ul>\n<p><strong>Answer: <\/strong>D) All of the above<\/p>\n<p><strong>8. What is the correct way to define a class in C++?<\/strong><\/p>\n<ul>\n<li>A) class MyClass;<\/li>\n<li>B) class MyClass {}<\/li>\n<li>C) class MyClass();<\/li>\n<li>D) class = MyClass;<\/li>\n<\/ul>\n<p><strong>Answer: <\/strong>B) class MyClass {}<\/p>\n<p><strong>9. What is the scope resolution operator in C++?<\/strong><\/p>\n<ul>\n<li>A) ::<\/li>\n<li>B) .<\/li>\n<li>C) -&gt;<\/li>\n<li>D) :<\/li>\n<\/ul>\n<p><strong>Answer: A) ::<\/strong><\/p>\n<p><strong>10. What is the output of the following code snippet?<\/strong><\/p>\n<ul>\n<li>A) Size of the array: 5<\/li>\n<li>B) Size of the array: 20<\/li>\n<li>C) Size of the array: 10<\/li>\n<li>D) Size of the array: 1<\/li>\n<\/ul>\n<p><strong>Answer: <\/strong>A) Size of the array: 5<\/p>\n<p><strong>11. Which of the following is the correct way to allocate dynamic memory for an array of integers in C++?<\/strong><\/p>\n<ul>\n<li>A) int* arr = new int[10];<\/li>\n<li>B) int* arr = malloc(10 * sizeof(int));<\/li>\n<li>C) int arr[10];<\/li>\n<li>D) int arr = new int[10];<\/li>\n<\/ul>\n<p>Answer: A) int* arr = new int[10];<\/p>\n<p><strong>12. What is the default access specifier for members of a class in C++?<\/strong><\/p>\n<ul>\n<li>A) Public<\/li>\n<li>B) Private<\/li>\n<li>C) Protected<\/li>\n<li>D) None<\/li>\n<\/ul>\n<p>Answer: B) Private<\/p>\n<p><strong>13. Which of the following is not a valid C++ loop construct?<\/strong><\/p>\n<ul>\n<li>A) for<\/li>\n<li>B) while<\/li>\n<li>C) do-while<\/li>\n<li>D) repeat-until<\/li>\n<\/ul>\n<p>Answer: D) repeat-until<\/p>\n<p><strong>14. What does the &#8220;this&#8221; pointer refer to in a class?<\/strong><\/p>\n<ul>\n<li>A) The previous object<\/li>\n<li>B) The next object<\/li>\n<li>C) The current object<\/li>\n<li>D) The parent object<\/li>\n<\/ul>\n<p>Answer: C) The current object<\/p>\n<p><strong>15. Which function is used to find the length of a string in C++?<\/strong><\/p>\n<ul>\n<li>A) size()<\/li>\n<li>B) length()<\/li>\n<li>C) strlen()<\/li>\n<li>D) all of the above<\/li>\n<\/ul>\n<p>Answer: D) all of the above<\/p>\n<p><strong>16. Which of the following operators cannot be overloaded in C++?<\/strong><\/p>\n<ul>\n<li>A) +<\/li>\n<li>B) &#8211;<\/li>\n<li>C) ::<\/li>\n<li>D) ==<\/li>\n<\/ul>\n<p>Answer: C) ::<\/p>\n<p><strong>17. What is the correct syntax for creating a reference variable in C++?<\/strong><\/p>\n<ul>\n<li>A) int &amp;ref = var;<\/li>\n<li>B) int ref = &amp;var;<\/li>\n<li>C) int ref = var;<\/li>\n<li>D) int *ref = var;<\/li>\n<\/ul>\n<p>Answer: A) int &amp;ref = var;<\/p>\n<p><strong>18. Which of the following is used to terminate a loop?<\/strong><\/p>\n<ul>\n<li>A) break<\/li>\n<li>B) continue<\/li>\n<li>C) exit<\/li>\n<li>D) end<\/li>\n<\/ul>\n<p>Answer: A) break<\/p>\n<p><strong>19. What is the output of the following code?<\/strong><\/p>\n<p>int a = 10;<br \/>\nint b = 20;<br \/>\nswap(a, b);<br \/>\ncout &lt;&lt; a &lt;&lt; &#8221; &#8221; &lt;&lt; b;<\/p>\n<ul>\n<li>A) 10 20<\/li>\n<li>B) 20 10<\/li>\n<li>C) Compiler error<\/li>\n<li>D) Runtime error<\/li>\n<\/ul>\n<p>Answer: C) Compiler error<\/p>\n<p><strong>20. Which of the following data types is used to store true\/false values in C++?<\/strong><\/p>\n<ul>\n<li>A) int<\/li>\n<li>B) bool<\/li>\n<li>C) char<\/li>\n<li>D) float<\/li>\n<\/ul>\n<p>Answer: B) bool<\/p>\n<p><strong>21. What is the return type of the main() function in C++?<\/strong><\/p>\n<ul>\n<li>A) void<\/li>\n<li>B) int<\/li>\n<li>C) char<\/li>\n<li>D) float<\/li>\n<\/ul>\n<p>Answer: B) int<\/p>\n<p><strong>22. Which header file is required to use the std::vector class?<\/strong><\/p>\n<ul>\n<li>A) &lt;vector&gt;<\/li>\n<li>B) &lt;array&gt;<\/li>\n<li>C) &lt;list&gt;<\/li>\n<li>D) &lt;stack&gt;<\/li>\n<\/ul>\n<p>Answer: A) &lt;vector&gt;<\/p>\n<p><strong>23. What is the output of the following code?<\/strong><\/p>\n<p>int x = 5;<br \/>\nint y = 10;<br \/>\ncout &lt;&lt; x + y &lt;&lt; endl;<\/p>\n<ul>\n<li>A) 5<\/li>\n<li>B) 10<\/li>\n<li>C) 15<\/li>\n<li>D) 0<\/li>\n<\/ul>\n<p>Answer: C) 15<\/p>\n<p><strong>24. Which of the following is not a type of constructor in C++?<\/strong><\/p>\n<ul>\n<li>A) Default constructor<\/li>\n<li>B) Copy constructor<\/li>\n<li>C) Move constructor<\/li>\n<li>D) Assign constructor<\/li>\n<\/ul>\n<p>Answer: D) Assign constructor<\/p>\n<p><strong>25. Which of the following statements is correct about destructors in C++?<\/strong><\/p>\n<ul>\n<li>A) They can be overloaded.<\/li>\n<li>B) They can have parameters.<\/li>\n<li>C) They do not have a return type.<\/li>\n<li>D) They are called manually.<\/li>\n<\/ul>\n<p>Answer: C) They do not have a return type.<\/p>\n<p><strong>26. What is the correct syntax to inherit a class in C++?<\/strong><\/p>\n<ul>\n<li>A) class Derived : public Base {};<\/li>\n<li>B) class Derived = Base {};<\/li>\n<li>C) class Derived inherits Base {};<\/li>\n<li>D) class Derived Base {};<\/li>\n<\/ul>\n<p>Answer: A) class Derived : public Base {};<\/p>\n<p><strong>27. What is the output of the following code?<\/strong><\/p>\n<p>int x = 10;<br \/>\nx += 5;<br \/>\ncout &lt;&lt; x &lt;&lt; endl;<\/p>\n<ul>\n<li>A) 5<\/li>\n<li>B) 10<\/li>\n<li>C) 15<\/li>\n<li>D) 20<\/li>\n<\/ul>\n<p>Answer: C) 15<\/p>\n<p><strong>28. Which keyword is used to handle exceptions in C++?<\/strong><\/p>\n<ul>\n<li>A) catch<\/li>\n<li>B) throw<\/li>\n<li>C) try<\/li>\n<li>D) all of the above<\/li>\n<\/ul>\n<p>Answer: D) all of the above<\/p>\n<p><strong>29. Which of the following is used to define a macro in C++?<\/strong><\/p>\n<ul>\n<li>A) #define<\/li>\n<li>B) #macro<\/li>\n<li>C) #include<\/li>\n<li>D) #pragma<\/li>\n<\/ul>\n<p>Answer: A) #define<\/p>\n<p><strong>30. What does the &#8216;new&#8217; keyword do in C++?<\/strong><\/p>\n<ul>\n<li>A) Allocates memory for a variable<\/li>\n<li>B) Deallocates memory for a variable<\/li>\n<li>C) Creates a new variable<\/li>\n<li>D) Deletes a variable<\/li>\n<\/ul>\n<p>Answer: A) Allocates memory for a variable<\/p>\n<p><strong>31. What is the output of the following code?<\/strong><\/p>\n<p>int arr[] = {1, 2, 3, 4, 5};<br \/>\ncout &lt;&lt; arr[2] &lt;&lt; endl;<\/p>\n<ul>\n<li>A) 1<\/li>\n<li>B) 2<\/li>\n<li>C) 3<\/li>\n<li>D) 4<\/li>\n<\/ul>\n<p>Answer: C) 3<\/p>\n<p><strong>32. What is a friend function in C++?<\/strong><\/p>\n<ul>\n<li>A) A function that is a member of a class<\/li>\n<li>B) A function that has access to the private and protected members of a class<\/li>\n<li>C) A function that is defined inside a class<\/li>\n<li>D) A function that is called within another function<\/li>\n<\/ul>\n<p>Answer: B) A function that has access to the private and protected members of a class<\/p>\n<p><strong>33. What is polymorphism in C++?<\/strong><\/p>\n<ul>\n<li>A) The ability to create multiple classes<\/li>\n<li>B) The ability to process objects differently based on their data type<\/li>\n<li>C) The ability to use one function for different purposes<\/li>\n<li>D) The ability to inherit properties from multiple classes<\/li>\n<\/ul>\n<p>Answer: B) The ability to process objects differently based on their data type<\/p>\n<p><strong>34. Which of the following is a valid way to declare an integer array of size 5?<\/strong><\/p>\n<ul>\n<li>A) int arr[5];<\/li>\n<li>B) int arr = new int[5];<\/li>\n<li>C) int arr(5);<\/li>\n<li>D) int arr[] = {5};<\/li>\n<\/ul>\n<p>Answer: A) int arr[5];<\/p>\n<p><strong>35. What is the output of the following code?<\/strong><\/p>\n<p>int a = 10;<br \/>\nint b = 20;<br \/>\nint c = a &gt; b ? a : b;<br \/>\ncout &lt;&lt; c &lt;&lt; endl;<\/p>\n<ul>\n<li>A) 10<\/li>\n<li>B) 20<\/li>\n<li>C) 30<\/li>\n<li>D) 0<\/li>\n<\/ul>\n<p>Answer: B) 20<\/p>\n<p><strong>36. Which of the following is not a storage class specifier in C++?<\/strong><\/p>\n<ul>\n<li>A) auto<\/li>\n<li>B) register<\/li>\n<li>C) static<\/li>\n<li>D) volatile<\/li>\n<\/ul>\n<p>Answer: D) volatile<\/p>\n<p><strong>37. Which of the following is true about virtual functions in C++?<\/strong><\/p>\n<ul>\n<li>A) They can be static.<\/li>\n<li>B) They are defined using the keyword virtual.<\/li>\n<li>C) They can have a different signature in derived classes.<\/li>\n<li>D) They cannot be overridden.<\/li>\n<\/ul>\n<p>Answer: B) They are defined using the keyword virtual.<\/p>\n<p><strong>38. Which of the following is a correct way to declare a function in C++?<\/strong><\/p>\n<ul>\n<li>A) void myFunction();<\/li>\n<li>B) function void myFunction();<\/li>\n<li>C) myFunction() void;<\/li>\n<li>D) void = myFunction();<\/li>\n<\/ul>\n<p>Answer: A) void myFunction();<\/p>\n<p><strong>39. What is encapsulation in C++?<\/strong><\/p>\n<ul>\n<li>A) The ability to hide the internal details of an object<\/li>\n<li>B) The ability to create objects from classes<\/li>\n<li>C) The ability to inherit properties from another class<\/li>\n<li>D) The ability to define multiple functions with the same name<\/li>\n<\/ul>\n<p>Answer: A) The ability to hide the internal details of an object<\/p>\n<p><strong>40. Which of the following is the correct way to declare a constant in C++?<\/strong><\/p>\n<ul>\n<li>A) const int x = 10;<\/li>\n<li>B) int const x = 10;<\/li>\n<li>C) both A and B<\/li>\n<li>D) none of the above<\/li>\n<\/ul>\n<p>Answer: C) both A and B<\/p>\n<p><strong>41. What is the purpose of the &#8216;using namespace std;&#8217; statement in C++?<\/strong><\/p>\n<ul>\n<li>A) It imports the standard library functions.<\/li>\n<li>B) It allows you to use standard library names without prefixing them with &#8216;std::&#8217;.<\/li>\n<li>C) It defines a new namespace called &#8216;std&#8217;.<\/li>\n<li>D) It includes the standard input\/output functions.<\/li>\n<\/ul>\n<p>Answer: B) It allows you to use standard library names without prefixing them with &#8216;std::&#8217;.<\/p>\n<p><strong>42. Which of the following is the correct way to define a pure virtual function in C++?<\/strong><\/p>\n<ul>\n<li>A) virtual void myFunction() = 0;<\/li>\n<li>B) void virtual myFunction() = 0;<\/li>\n<li>C) pure virtual void myFunction();<\/li>\n<li>D) virtual void myFunction() {0};<\/li>\n<\/ul>\n<p>Answer: A) virtual void myFunction() = 0;<\/p>\n<p><strong>43. What does the keyword &#8216;mutable&#8217; signify in C++?<\/strong><\/p>\n<ul>\n<li>A) It allows a member of an object to be modified even if the object is const.<\/li>\n<li>B) It declares a variable that can change its type at runtime.<\/li>\n<li>C) It indicates a variable that can only be modified once.<\/li>\n<li>D) It specifies a variable that is shared across all instances of a class.<\/li>\n<\/ul>\n<p>Answer: A) It allows a member of an object to be modified even if the object is const.<\/p>\n<p><strong>44. Which of the following is not a feature of object-oriented programming in C++?<\/strong><\/p>\n<ul>\n<li>A) Inheritance<\/li>\n<li>B) Polymorphism<\/li>\n<li>C) Encapsulation<\/li>\n<li>D) Compilation<\/li>\n<\/ul>\n<p>Answer: D) Compilation<\/p>\n<p><strong>45. What is the output of the following code?<\/strong><\/p>\n<p>int arr[] = {10, 20, 30, 40, 50};<br \/>\ncout &lt;&lt; arr[3] &lt;&lt; endl;<\/p>\n<ul>\n<li>A) 10<\/li>\n<li>B) 20<\/li>\n<li>C) 30<\/li>\n<li>D) 40<\/li>\n<\/ul>\n<p>Answer: D) 40<\/p>\n<p><strong>46. Which of the following cannot be used with the &#8216;this&#8217; pointer in C++?<\/strong><\/p>\n<ul>\n<li>A) Static member functions<\/li>\n<li>B) Non-static member functions<\/li>\n<li>C) Member variables<\/li>\n<li>D) Member functions<\/li>\n<\/ul>\n<p>Answer: A) Static member functions<\/p>\n<p><strong>47. What is the correct syntax for declaring a function template in C++?<\/strong><\/p>\n<ul>\n<li>A) template &lt;class T&gt; void myFunction(T param);<\/li>\n<li>B) template void myFunction&lt;T&gt;(T param);<\/li>\n<li>C) template &lt;T&gt; void myFunction(class param);<\/li>\n<li>D) template &lt;class T&gt; T void myFunction(T param);<\/li>\n<\/ul>\n<p>Answer: A) template &lt;class T&gt; void myFunction(T param);<\/p>\n<p><strong>48. What is the output of the following code?<\/strong><\/p>\n<p>int x = 10;<br \/>\nint y = 20;<br \/>\nif (x &lt; y) {<br \/>\ncout &lt;&lt; &#8220;x is less than y&#8221; &lt;&lt; endl;<br \/>\n}<\/p>\n<ul>\n<li>A) x is less than y<\/li>\n<li>B) x is greater than y<\/li>\n<li>C) x is equal to y<\/li>\n<li>D) No output<\/li>\n<\/ul>\n<p>Answer: A) x is less than y<\/p>\n<p><strong>49. Which of the following correctly describes a constructor in C++?<\/strong><\/p>\n<ul>\n<li>A) A function that is called when an object is destroyed.<\/li>\n<li>B) A function that is used to copy one object to another.<\/li>\n<li>C) A function that initializes the member variables of an object.<\/li>\n<li>D) A function that is used to perform some operation on an object.<\/li>\n<\/ul>\n<p>Answer: C) A function that initializes the member variables of an object.<\/p>\n<p><strong>50. What is the output of the following code?<\/strong><\/p>\n<p>int a = 5;<br \/>\nint b = 10;<br \/>\nswap(a, b);<br \/>\ncout &lt;&lt; a &lt;&lt; &#8221; &#8221; &lt;&lt; b &lt;&lt; endl;<\/p>\n<ul>\n<li>A) 5 10<\/li>\n<li>B) 10 5<\/li>\n<li>C) Compiler error<\/li>\n<li>D) Runtime error<\/li>\n<\/ul>\n<p>Answer: C) Compiler error<\/p>\n<h2><span class=\"ez-toc-section\" id=\"FAQs_on_C\"><\/span>FAQs on C++<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\t\t<section class=\"sc_fs_faq sc_card \">\n\t\t\t<div>\n\t\t\t\t<h3><span class=\"ez-toc-section\" id=\"What_is_the_advantage_of_C\"><\/span>What is the advantage of C++?<span class=\"ez-toc-section-end\"><\/span><\/h3>\t\t\t\t<div>\n\t\t\t\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\tThe main advantage of C++ is its ability to provide a high level of control over system resources and memory. This allows developers to create efficient and scalable applications that can run on multiple platforms. Additionally, C++ supports object-oriented programming, which makes it easier to write reusable and maintainable code.\t\t\t\t\t<\/p>\n\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"sc_fs_faq sc_card \">\n\t\t\t<div>\n\t\t\t\t<h3><span class=\"ez-toc-section\" id=\"Is_C_very_useful\"><\/span>Is C++ very useful?<span class=\"ez-toc-section-end\"><\/span><\/h3>\t\t\t\t<div>\n\t\t\t\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\tYes, C++ is a very useful programming language. It is widely used in various industries such as finance, app development, game development, and virtual reality. C++ is also used in operating systems, graphical user interfaces, and embedded systems. Its versatility and performance make it a popular choice for many applications.\t\t\t\t\t<\/p>\n\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"sc_fs_faq sc_card \">\n\t\t\t<div>\n\t\t\t\t<h3><span class=\"ez-toc-section\" id=\"What_is_OOPS_in_C\"><\/span>What is OOPS in C++?<span class=\"ez-toc-section-end\"><\/span><\/h3>\t\t\t\t<div>\n\t\t\t\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\tObject-Oriented Programming (OOPS) in C++ is a programming paradigm that organizes code into objects that contain both data and functions. This allows developers to create reusable and maintainable code by defining classes and objects that encapsulate data and behavior. OOPS in C++ helps to keep the code DRY (Don't Repeat Yourself) and makes it easier to maintain, modify, and debug.\t\t\t\t\t<\/p>\n\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"sc_fs_faq sc_card \">\n\t\t\t<div>\n\t\t\t\t<h3><span class=\"ez-toc-section\" id=\"Who_invented_C\"><\/span>Who invented C++?<span class=\"ez-toc-section-end\"><\/span><\/h3>\t\t\t\t<div>\n\t\t\t\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\tC++ was invented by Bjarne Stroustrup as an extension to the C language. He developed C++ in the 1980s to provide a more powerful and flexible programming language that could handle complex applications.\t\t\t\t\t<\/p>\n\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"sc_fs_faq sc_card \">\n\t\t\t<div>\n\t\t\t\t<h3><span class=\"ez-toc-section\" id=\"What_is_the_basic_concept_of_C\"><\/span>What is the basic concept of C++?<span class=\"ez-toc-section-end\"><\/span><\/h3>\t\t\t\t<div>\n\t\t\t\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\tWhat is the basic concept of C++? The basic concept of C++ is to provide a high-level programming language that can be used to create efficient and scalable applications. C++ is designed to be portable and can be used to develop applications that can run on multiple platforms. The language is also designed to be flexible and can be used for a wide range of applications, from operating systems to graphical user interfaces.\t\t\t\t\t<\/p>\n\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t<\/section>\n\t\t\n<script type=\"application\/ld+json\">\n\t{\n\t\t\"@context\": \"https:\/\/schema.org\",\n\t\t\"@type\": \"FAQPage\",\n\t\t\"mainEntity\": [\n\t\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"What is the advantage of C++?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"The main advantage of C++ is its ability to provide a high level of control over system resources and memory. This allows developers to create efficient and scalable applications that can run on multiple platforms. Additionally, C++ supports object-oriented programming, which makes it easier to write reusable and maintainable code.\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"Is C++ very useful?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"Yes, C++ is a very useful programming language. It is widely used in various industries such as finance, app development, game development, and virtual reality. C++ is also used in operating systems, graphical user interfaces, and embedded systems. Its versatility and performance make it a popular choice for many applications.\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"What is OOPS in C++?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"Object-Oriented Programming (OOPS) in C++ is a programming paradigm that organizes code into objects that contain both data and functions. This allows developers to create reusable and maintainable code by defining classes and objects that encapsulate data and behavior. OOPS in C++ helps to keep the code DRY (Don't Repeat Yourself) and makes it easier to maintain, modify, and debug.\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"Who invented C++?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"C++ was invented by Bjarne Stroustrup as an extension to the C language. He developed C++ in the 1980s to provide a more powerful and flexible programming language that could handle complex applications.\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"What is the basic concept of C++?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"What is the basic concept of C++? The basic concept of C++ is to provide a high-level programming language that can be used to create efficient and scalable applications. C++ is designed to be portable and can be used to develop applications that can run on multiple platforms. The language is also designed to be flexible and can be used for a wide range of applications, from operating systems to graphical user interfaces.\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t\t\t\t]\n\t}\n<\/script>\n\n","protected":false},"excerpt":{"rendered":"<p>What is C++? C++ is a programming language that allows developers to create software applications. It is an extension of [&hellip;]<\/p>\n","protected":false},"author":53,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_yoast_wpseo_focuskw":"C++ mcq","_yoast_wpseo_title":"50 C++ MCQ Questions for Placement with Answer","_yoast_wpseo_metadesc":"C++ is a programming language that allows developers to create software applications. It is an extension of the C programming language and is known for its efficiency and flexibility","custom_permalink":"mcqs\/class-12-computer-science-cpp\/"},"categories":[11038],"tags":[],"table_tags":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v17.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>50 C++ MCQ Questions for Placement with Answer<\/title>\n<meta name=\"description\" content=\"C++ is a programming language that allows developers to create software applications. It is an extension of the C programming language and is known for its efficiency and flexibility\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"50 C++ MCQ Questions for Placement with Answer\" \/>\n<meta property=\"og:description\" content=\"C++ is a programming language that allows developers to create software applications. It is an extension of the C programming language and is known for its efficiency and flexibility\" \/>\n<meta property=\"og:url\" content=\"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/\" \/>\n<meta property=\"og:site_name\" content=\"Infinity Learn by Sri Chaitanya\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/InfinityLearn.SriChaitanya\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-06-01T12:26:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-15T06:12:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/infinitylearn.com\/surge\/wp-content\/uploads\/2025\/04\/infinitylearn.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1008\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@InfinityLearn_\" \/>\n<meta name=\"twitter:site\" content=\"@InfinityLearn_\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ankit\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"50 C++ MCQ Questions for Placement with Answer","description":"C++ is a programming language that allows developers to create software applications. It is an extension of the C programming language and is known for its efficiency and flexibility","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/","og_locale":"en_US","og_type":"article","og_title":"50 C++ MCQ Questions for Placement with Answer","og_description":"C++ is a programming language that allows developers to create software applications. It is an extension of the C programming language and is known for its efficiency and flexibility","og_url":"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/","og_site_name":"Infinity Learn by Sri Chaitanya","article_publisher":"https:\/\/www.facebook.com\/InfinityLearn.SriChaitanya\/","article_published_time":"2024-06-01T12:26:50+00:00","article_modified_time":"2025-05-15T06:12:22+00:00","og_image":[{"width":1920,"height":1008,"url":"https:\/\/infinitylearn.com\/surge\/wp-content\/uploads\/2025\/04\/infinitylearn.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_creator":"@InfinityLearn_","twitter_site":"@InfinityLearn_","twitter_misc":{"Written by":"Ankit","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Organization","@id":"https:\/\/infinitylearn.com\/surge\/#organization","name":"Infinity Learn","url":"https:\/\/infinitylearn.com\/surge\/","sameAs":["https:\/\/www.facebook.com\/InfinityLearn.SriChaitanya\/","https:\/\/www.instagram.com\/infinitylearn_by_srichaitanya\/","https:\/\/www.linkedin.com\/company\/infinity-learn-by-sri-chaitanya\/","https:\/\/www.youtube.com\/c\/InfinityLearnEdu","https:\/\/twitter.com\/InfinityLearn_"],"logo":{"@type":"ImageObject","@id":"https:\/\/infinitylearn.com\/surge\/#logo","inLanguage":"en-US","url":"","contentUrl":"","caption":"Infinity Learn"},"image":{"@id":"https:\/\/infinitylearn.com\/surge\/#logo"}},{"@type":"WebSite","@id":"https:\/\/infinitylearn.com\/surge\/#website","url":"https:\/\/infinitylearn.com\/surge\/","name":"Infinity Learn by Sri Chaitanya","description":"Surge","publisher":{"@id":"https:\/\/infinitylearn.com\/surge\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/infinitylearn.com\/surge\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/#webpage","url":"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/","name":"50 C++ MCQ Questions for Placement with Answer","isPartOf":{"@id":"https:\/\/infinitylearn.com\/surge\/#website"},"datePublished":"2024-06-01T12:26:50+00:00","dateModified":"2025-05-15T06:12:22+00:00","description":"C++ is a programming language that allows developers to create software applications. It is an extension of the C programming language and is known for its efficiency and flexibility","breadcrumb":{"@id":"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/infinitylearn.com\/surge\/"},{"@type":"ListItem","position":2,"name":"C++ MCQ Questions and Answers"}]},{"@type":"Article","@id":"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/#article","isPartOf":{"@id":"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/#webpage"},"author":{"@id":"https:\/\/infinitylearn.com\/surge\/#\/schema\/person\/d647d4ff3a1111ff8eeccdb6b12651cb"},"headline":"C++ MCQ Questions and Answers","datePublished":"2024-06-01T12:26:50+00:00","dateModified":"2025-05-15T06:12:22+00:00","mainEntityOfPage":{"@id":"https:\/\/infinitylearn.com\/surge\/mcqs\/class-12-computer-science-cpp\/#webpage"},"wordCount":2372,"publisher":{"@id":"https:\/\/infinitylearn.com\/surge\/#organization"},"articleSection":["MCQs"],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/infinitylearn.com\/surge\/#\/schema\/person\/d647d4ff3a1111ff8eeccdb6b12651cb","name":"Ankit","image":{"@type":"ImageObject","@id":"https:\/\/infinitylearn.com\/surge\/#personlogo","inLanguage":"en-US","url":"https:\/\/secure.gravatar.com\/avatar\/b1068bdc2711bd9c9f8be3b229f758f6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b1068bdc2711bd9c9f8be3b229f758f6?s=96&d=mm&r=g","caption":"Ankit"},"url":"https:\/\/infinitylearn.com\/surge\/author\/ankit\/"}]}},"_links":{"self":[{"href":"https:\/\/infinitylearn.com\/surge\/wp-json\/wp\/v2\/posts\/720158"}],"collection":[{"href":"https:\/\/infinitylearn.com\/surge\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/infinitylearn.com\/surge\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/infinitylearn.com\/surge\/wp-json\/wp\/v2\/users\/53"}],"replies":[{"embeddable":true,"href":"https:\/\/infinitylearn.com\/surge\/wp-json\/wp\/v2\/comments?post=720158"}],"version-history":[{"count":0,"href":"https:\/\/infinitylearn.com\/surge\/wp-json\/wp\/v2\/posts\/720158\/revisions"}],"wp:attachment":[{"href":"https:\/\/infinitylearn.com\/surge\/wp-json\/wp\/v2\/media?parent=720158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/infinitylearn.com\/surge\/wp-json\/wp\/v2\/categories?post=720158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/infinitylearn.com\/surge\/wp-json\/wp\/v2\/tags?post=720158"},{"taxonomy":"table_tags","embeddable":true,"href":"https:\/\/infinitylearn.com\/surge\/wp-json\/wp\/v2\/table_tags?post=720158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}