C++ MCQs with answers Page - 153

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 the 'void' keyword in C++ represent?

  • (A) A function that does not return any value
  • (B) A variable with no value
  • (C) A data type used for memory management
  • (D) A constant value

A

Admin • 833.24K Points
Coach

Q. Which of the following will correctly initialize a dynamic array of integers with 10 elements?

  • (A) int* arr = new int[10];
  • (B) int arr[10] = new[];
  • (C) int* arr = malloc(10 * sizeof(int));
  • (D) int arr[10] = new int[10];

A

Admin • 833.24K Points
Coach

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

int a = 7;
cout << a >> 1;

  • (A) 14
  • (B) 3
  • (C) 7
  • (D) 1

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct syntax to declare a static variable in C++?

  • (A) int static a;
  • (B) static int a;
  • (C) static a int;
  • (D) int a static;

A

Admin • 833.24K Points
Coach

Q. What is the purpose of the 'this' pointer in C++?

  • (A) It points to the current object of a class.
  • (B) It is used to access global variables.
  • (C) It is used to define static functions.
  • (D) It is used for memory allocation.

A

Admin • 833.24K Points
Coach

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

  • (A) A destructor is called when an object is created.
  • (B) A destructor has the same name as the class with a '~' prefix.
  • (C) A destructor can be overloaded.
  • (D) A destructor returns a value.

A

Admin • 833.24K Points
Coach

Q. Which of the following is not a valid C++ keyword?

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

A

Admin • 833.24K Points
Coach

Q. What is the result of the following expression in C++: '5 / 2'?

  • (A) 2.5
  • (B) 2
  • (C) 3
  • (D) Error

A

Admin • 833.24K Points
Coach

Q. Which of the following can be used to define a function in C++?

  • (A) function keyword
  • (B) fn keyword
  • (C) def keyword
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. Which of the following C++ keywords is used to declare a constant?

  • (A) constant
  • (B) const
  • (C) final
  • (D) immutable

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