C++ MCQs with answers Page - 32

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 is the output of the following C++ code?

Code:
#include <iostream>
using namespace std;
void display()
void display()
{
  cout << "Hello World!";
}
int main()
{
  display();
  return 0;
}
  • (A) Hello World!
  • (B) Hello World!Hello World!
  • (C) Compilation error.
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. The explicit keyword is an optional decoration for the constructors that takes exactly_____argument.

  • (A) No argument
  • (B) Two
  • (C) Three
  • (D) One

A

Admin • 833.24K Points
Coach

Q. A class can contain objects of other classes and this phenomenon is called_________ .

  • (A) Relationship
  • (B) Object Association
  • (C) Containership
  • (D) None of these

A

Admin • 833.24K Points
Coach

Q. If a class contains pure virtual function, then it is termed as____________________ .

  • (A) Virtual class
  • (B) Sealed class
  • (C) Pure Local class
  • (D) Abstract Class

A

Admin • 833.24K Points
Coach

Q. If inner catch handler is not able to handle the exception then__________ .

  • (A) Compiler will look for outer try handler
  • (B) Program terminates abnormally
  • (C) Compiler will check for appropriate catch handler of outer try block
  • (D) None of these

A

Admin • 833.24K Points
Coach

Q. Generic catch handler is represented by ______________ .

  • (A) catch(..,)
  • (B) catch(---)
  • (C) catch(…)
  • (D) catch( void x)

A

Admin • 833.24K Points
Coach

Q. Which one is suitable syntax for function template?

  • (A) template< class T> return_type Function_Name(parameters)
  • (B) template< typename T> return_type Function_Name(parameters)
  • (C) both a and b
  • (D) None of these

A

Admin • 833.24K Points
Coach

Q. While overloading binary operators using member function, it requires ___ argument/s.

  • (A) Zero
  • (B) One
  • (C) Two
  • (D) Three

A

Admin • 833.24K Points
Coach

Q. If abstract class is inherited by derived class, then_______________ .

  • (A) Derived class should provide definition for all the pure virtual functions
  • (B) Derived class also become abstract if fails to implement pure virtual functions
  • (C) Objects of derived class can’t be created if it fails to implement pure virtual functions
  • (D) All of these

A

Admin • 833.24K Points
Coach

Q. __________are used for generic programming.

  • (A) Virtual Functions
  • (B) Inheritance
  • (C) Templates
  • (D) None of these