C++ MCQs with answers Page - 115

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 followings is/are automatically added to every class, if we do not write our own?

  • (A) Copy Constructor
  • (B) Assignment Operator
  • (C) A constructor without any parameter
  • (D) All of the above

A

Admin • 833.24K Points
Coach

Q. Constructors have _____ return type.

  • (A) void
  • (B) char
  • (C) int
  • (D) no

A

Admin • 833.24K Points
Coach

Q. Implicit return type of a class constructor is:

  • (A) not of class type itself
  • (B) class type itself
  • (C) a destructor of class type
  • (D) a destructor not of class type

A

Admin • 833.24K Points
Coach

Q. Which of the following is true about constructors?
1) They cannot be virtual.
2) They cannot be private.
3) They are automatically called by new operator.

  • (A) All 1, 2, and 3
  • (B) Only 1 and 3
  • (C) Only 1 and 2
  • (D) Only 2 and 3

A

Admin • 833.24K Points
Coach

Q. Output of following program?
#include<iostream>
using namespace std;
class Point {
Point() { cout << "Constructor called"; }
}; int main()
{
Point t1;
return 0;
}

  • (A) Compiler Error
  • (B) Runtime Error
  • (C) Constructor called
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. #include<iostream>
using namespace std;
class Point {
public:
Point() { cout << "Constructor called"; }
};
int main()
{
Point t1, *t2;
return 0;
}

  • (A) Compiler Error
  • (B) Constructor called Constructor called
  • (C) Constructor called
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. Which operator is having the highest precedence?

  • (A) postfix
  • (B) unary
  • (C) shift
  • (D) equality

A

Admin • 833.24K Points
Coach

Q. Which of the following is FALSE about references in C++?

  • (A) References cannot be NULL
  • (B) A reference must be initialized when declared
  • (C) Once a reference is created, it cannot be later made to reference another object; it cannot be reset.
  • (D) References cannot refer to constant value

A

Admin • 833.24K Points
Coach

Q. Which of the following functions must use reference?

  • (A) Assignment operator function
  • (B) Copy Constructor
  • (C) Destructor
  • (D) Parameterized constructor

A

Admin • 833.24K Points
Coach

Q. Output of following C++ program?
#include<iostream>
using namespace std;
int main()
{
int x = 10;
int& ref = x;
ref = 20;
cout << "x = " << x << endl ;
x = 30;
cout << "ref = " << ref << endl;
return 0;
}

  • (A) x = 20; ref = 30
  • (B) x = 20; ref = 20
  • (C) x = 10; ref = 30
  • (D) x = 30; ref = 30

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