C++ MCQs with answers Page - 143

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 constant pointer in C++?

  • (A) int* const ptr;
  • (B) const int* ptr;
  • (C) int const* ptr;
  • (D) const ptr* int;

A

Admin • 833.24K Points
Coach

Q. What is the purpose of the 'new' keyword in C++?

  • (A) To allocate memory on the stack
  • (B) To deallocate memory
  • (C) To allocate memory on the heap
  • (D) To define a constant

A

Admin • 833.24K Points
Coach

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

  • (A) for
  • (B) while
  • (C) repeat
  • (D) do-while

A

Admin • 833.24K Points
Coach

Q. Which operator is used to allocate memory dynamically in C++?

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

A

Admin • 833.24K Points
Coach

Q. What is the default access specifier for class members in C++?

  • (A) private
  • (B) public
  • (C) protected
  • (D) friend

A

Admin • 833.24K Points
Coach

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

  • (A) var
  • (B) auto
  • (C) integer
  • (D) staticx

A

Admin • 833.24K Points
Coach

Q. What is the purpose of the 'delete' keyword in C++?

  • (A) To deallocate memory
  • (B) To allocate memory
  • (C) To delete a variable
  • (D) To stop program execution

A

Admin • 833.24K Points
Coach

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

  • (A) int
  • (B) float
  • (C) decimal
  • (D) double

A

Admin • 833.24K Points
Coach

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

  • (A) To define a class
  • (B) To avoid name conflicts
  • (C) To store variables globally
  • (D) To allocate memory

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct syntax to include a header file in C++?

  • (A) #include <iostream>
  • (B) #include [iostream]
  • (C) #include {iostream}
  • (D) #include 'iostream'

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