C++ MCQs with answers Page - 157

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 ? 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 function with an override specifier in C++?

  • (A) void myFunction() override { }
  • (B) void myFunction() { }
  • (C) Both A and B
  • (D) None of the above

A

Admin • 833.24K Points
Coach

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

  • (A) void myFunction() final { }
  • (B) void myFunction() { }
  • (C) Both A and B
  • (D) None of the above

A

Admin • 833.24K Points
Coach

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

  • (A) constexpr void myFunction() { }
  • (B) void myFunction() constexpr { }
  • (C) Both A and B
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. Which of the following is true about constructors in C++?

  • (A) They have the same name as the class
  • (B) They do not have a return type
  • (C) They are automatically called when an object is created
  • (D) All of the above

A

Admin • 833.24K Points
Coach

Q. Which operator is used for dynamic memory allocation in C++?

  • (A) malloc
  • (B) new
  • (C) alloc
  • (D) allocate

A

Admin • 833.24K Points
Coach

Q. What is the output of the following C++ code?

int x = 10;
cout << ++x;

  • (A) 9
  • (B) 10
  • (C) 11
  • (D) Compilation error

A

Admin • 833.24K Points
Coach

Q. Which C++ keyword is used to define an abstract class?

  • (A) abstract
  • (B) virtual
  • (C) pure
  • (D) class

A

Admin • 833.24K Points
Coach

Q. Which data type is used to store a sequence of characters in C++?

  • (A) char
  • (B) string
  • (C) array
  • (D) Both A and B

A

Admin • 833.24K Points
Coach

Q. Which C++ feature allows a derived class to inherit members from a base class?

  • (A) Encapsulation
  • (B) Polymorphism
  • (C) Inheritance
  • (D) Abstraction

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