C++ MCQs with answers Page - 149

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. Which of the following is the correct way to define a class template in C++?

  • (A) template <typename T> class MyClass { };
  • (B) template <class T> class MyClass { };
  • (C) Both A and B
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. What is the output of the following code snippet? int x = 10; int y = 20; cout << (x != y);

  • (A) 0
  • (B) 1
  • (C) 10
  • (D) 20

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct way to define a member function outside a class template in C++?

  • (A) template <typename T> void MyClass<T>::myFunction() { }
  • (B) template <class T> void MyClass<T>::myFunction() { }
  • (C) Both A and B
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. What is the output of the following code snippet? int x = 10; int y = 20; cout << (x < y);

  • (A) 0
  • (B) 1
  • (C) 10
  • (D) 20

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct way to define a static member function in C++?

  • (A) static void myFunction();
  • (B) void static myFunction();
  • (C) Both A and B
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. What is the output of the following code snippet? int x = 10; int y = 20; cout << (x > y);

  • (A) 0
  • (B) 1
  • (C) 10
  • (D) 20

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct way to define a const member function in C++?

  • (A) void myFunction() const;
  • (B) const void myFunction();
  • (C) Both A and B
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. What is the output of the following code snippet? int x = 10; int y = 20; cout << (x <= y);

  • (A) 0
  • (B) 1
  • (C) 10
  • (D) 20

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct way to define a mutable member variable in C++?

  • (A) mutable int x;
  • (B) int mutable x;
  • (C) Both A and B
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. What is the output of the following code snippet? int x = 10; int y = 20; cout << (x >= y);

  • (A) 0
  • (B) 1
  • (C) 10
  • (D) 20

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