C++ MCQs with answers Page - 147

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 code snippet? int x = 10; int y = 20; cout << (x / y);

  • (A) 0
  • (B) 0.5
  • (C) 2
  • (D) Error

A

Admin • 833.24K Points
Coach

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

  • (A) auto myLambda = [](int x) { return x * x; };
  • (B) lambda myLambda = [](int x) { return x * 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) 10
  • (B) 20
  • (C) 0
  • (D) Error

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct way to define a move constructor in C++?

  • (A) MyClass(MyClass&& other) { }
  • (B) MyClass(MyClass& other) { }
  • (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) 10
  • (B) 20
  • (C) 0
  • (D) Error

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct way to define a move assignment operator in C++?

  • (A) MyClass& operator=(MyClass&& other) { }
  • (B) MyClass& operator=(MyClass& other) { }
  • (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) 10
  • (B) 20
  • (C) 30
  • (D) Error

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct way to define a copy constructor in C++?

  • (A) MyClass(const MyClass& other) { }
  • (B) MyClass(MyClass& other) { }
  • (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) 10
  • (B) 20
  • (C) 30
  • (D) Error

A

Admin • 833.24K Points
Coach

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

  • (A) 10
  • (B) 20
  • (C) 40
  • (D) Error

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