C++ MCQs with answers Page - 148

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 destructor in a derived class in C++?

  • (A) ~DerivedClass() { }
  • (B) void ~DerivedClass() { }
  • (C) int ~DerivedClass() { }
  • (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 >> 1);

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

A

Admin • 833.24K Points
Coach

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

  • (A) int (*ptr)(int, int);
  • (B) int *ptr(int, int);
  • (C) int ptr(int, int);
  • (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) 0
  • (B) 1
  • (C) 10
  • (D) 20

A

Admin • 833.24K Points
Coach

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

  • (A) union MyUnion { int x; float y; };
  • (B) struct MyUnion { int x; float y; };
  • (C) class MyUnion { int x; float y; };
  • (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 = 0; cout << (x || y);

  • (A) 0
  • (B) 1
  • (C) 10
  • (D) 20

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct way to define an enumeration in C++?

  • (A) enum MyEnum { RED, GREEN, BLUE };
  • (B) struct MyEnum { RED, GREEN, BLUE };
  • (C) class MyEnum { RED, GREEN, BLUE };
  • (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);

  • (A) 0
  • (B) 1
  • (C) 10
  • (D) 20

A

Admin • 833.24K Points
Coach

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

  • (A) struct MyStruct { int x; float y; };
  • (B) class MyStruct { int x; float y; };
  • (C) union MyStruct { int x; float y; };
  • (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) 0
  • (B) 1
  • (C) 10
  • (D) 20

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