C++ MCQs with answers Page - 70

Here, you will find a collection of MCQ questions on C++. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 833.24K Points
Coach

Q. What does polymorphism stand for?

  • (A) a class that has two forms
  • (B) a class that has four forms
  • (C) a class that has many forms
  • (D) a class that has only a single form

A

Admin • 833.24K Points
Coach

Q. What handler do we use if we want to handle all the types of exceptions?

  • (A) catch-none handler
  • (B) try-catch handler
  • (C) catch-all handler
  • (D) catch handler

A

Admin • 833.24K Points
Coach

Q. What do we use in order to throw an exception?

  • (A) try
  • (B) throw
  • (C) handler
  • (D) catch

A

Admin • 833.24K Points
Coach

Q. We can apply RTTI to which of the class types?

  • (A) Polymorphic
  • (B) Encapsulation
  • (C) Derived
  • (D) Static

A

Admin • 833.24K Points
Coach

Q. Which header file do we use for the generation of random numbers?

  • (A) <random>
  • (B) <generator>
  • (C) <distribution>
  • (D) <gen_dist>

A

Admin • 833.24K Points
Coach

Q. Which container is the best for keeping a collection of various distinct elements?

  • (A) queue
  • (B) set
  • (C) heap
  • (D) multimap

A

Admin • 833.24K Points
Coach

Q. What will be the output of the following C++ code?

Code:
        #include <iostream>

        #include <string>

        #include <algorithm>

        using namespace std;

        int main() 

        {

            string s = "Hello World";

            s.erase(remove(s.begin(), s.end(),  ), s.end() ) ;

            cout << s << endl;

        }
  • (A) HelloWorld
  • (B) Hello World
  • (C) World
  • (D) Hello

A

Admin • 833.24K Points
Coach

Q. Which of the following C++ code will give error on compilation?

Code:
================code 1=================
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	cout<<"Hello World";
	return 0;
}
========================================
================code 2=================
#include <iostream>
int main(int argc, char const *argv[])
{
	std::cout<<"Hello World";
	return 0;
}
========================================
  • (A) Code 1 only
  • (B) Neither code 1 nor code 2
  • (C) Both code 1 and code 2
  • (D) Code 2 only

A

Admin • 833.24K Points
Coach

Q. Inheritance models which type of relationship?

  • (A) Belongs-to relationship
  • (B) Part-Of relationship
  • (C) Is-A relationship
  • (D) Has-A relationship

A

Admin • 833.24K Points
Coach

Q. In heap, which of these values will be pointed out first?

  • (A) First value
  • (B) Lowest value
  • (C) Third value
  • (D) Highest value

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ