C++ MCQs with answers Page - 13

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. Objects created using new operator are stored in __ memory.

  • (A) Cache
  • (B) Heap
  • (C) Stack
  • (D) None of the above.

A

Admin • 833.24K Points
Coach

Q. With respective to streams >> (operator) is called as

  • (A) Insertion operator
  • (B) Extraction operator
  • (C) Right shift operator
  • (D) Left shift operator

A

Admin • 833.24K Points
Coach

Q. What is the output of the following program?

Code:
#include 
using namespace std;
 
int main () {
   // local variable declaration:
   int x = 1;

   switch(x) {
   case 1 :
      cout << "Hi!" << endl; 
      break;
   default :
      cout << "Hello!" << endl;
   }
}
  • (A) Hello
  • (B) Hi
  • (C) HelloHi
  • (D) Compiler error

A

Admin • 833.24K Points
Coach

Q. What is the output of the following program?

Code:
                                                                                                                                                                                                                                                                            
  • (A) 1
  • (B) 0
  • (C) 2
  • (D) Compiler error

A

Admin • 833.24K Points
Coach

Q. Which of the following is CPP style type-casting?

  • (A) per = total/(float)m
  • (B) per = total/float(m)
  • (C) per = (float)total/m
  • (D) None of these

A

Admin • 833.24K Points
Coach

Q. If a program uses Inline Function, then the function is expanded inline at ___________.

  • (A) Compile time
  • (B) Run time
  • (C) Both a and b
  • (D) None of these

A

Admin • 833.24K Points
Coach

Q. Which of the following is/are valid ways to allocate memory for an integer by dynamic memory allocation in CPP?

  • (A) int *p = new int(100);
  • (B) int *p; p = new int; *p = 100;
  • (C) int *p = NULL; p = new int; *p=100;
  • (D) All of the above

A

Admin • 833.24K Points
Coach

Q. Which of the following is the perfect set of operators that can’t be overloaded in CPP ?

  • (A) +=, ?, :: , >>
  • (B) >>, <<, ?, *, sizeof()
  • (C) :: , . , .* , ?:
  • (D) :: , ->, * , new, delete

A

Admin • 833.24K Points
Coach

Q. Static variable in a class is initialized when _____ .

  • (A) every object of the class is created.
  • (B) last object of the class is created.
  • (C) first object of the class is created.
  • (D) No need to initialize static variable.

A

Admin • 833.24K Points
Coach

Q. To perform File I/O operations, we must use _____________ header file.

  • (A) < ifstream>
  • (B) < ofstream>
  • (C) < fstream>
  • (D) Any of these

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