C++ MCQs with answers Page - 84

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. Implicit return type of a class constructor is:

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

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) Only 1 and 3
  • (B) Only 1 and 2
  • (C) Only 2 and 3
  • (D) 1, 2, and 3

A

Admin • 833.24K Points
Coach

Q. Output of following program?

Code:
#include<iostream>
using namespace std;
class Point {
Point() { cout << "Constructor called"; }
}; int main()
{
Point t1;
return 0;
}
  • (A) Constructor called
  • (B) Runtime Error
  • (C) Compiler Error
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. Which operator is having the highest precedence?

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

A

Admin • 833.24K Points
Coach

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

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

A

Admin • 833.24K Points
Coach

Q. Which of the following functions must use reference?

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

A

Admin • 833.24K Points
Coach

Q. Output of following C++ program?

Code:
#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 = 30; ref = 30
  • (B) x = 10; ref = 30
  • (C) x = 20; ref = 20
  • (D) x = 20; ref = 30

A

Admin • 833.24K Points
Coach

Q. Predict the output of following C++ program.

Code:
#include<iostream>
using namespace std;
class Empty {};
int main() {
cout << sizeof(Empty);
return 0;
}
  • (A) 0
  • (B) A non-zero value
  • (C) Runtime Error
  • (D) Compiler Error

A

Admin • 833.24K Points
Coach

Q. Output of following C++ program?

Code:
class Test {
int x;
};
int main() {
Test t;
cout << t.x;
return 0;
}
  • (A) 0
  • (B) Garbage Value
  • (C) Compiler Error
  • (D) None of these

A

Admin • 833.24K Points
Coach

Q. Which of the following is true?

  • (A) All objects of a class share all data members of class
  • (B) Objects of a class do not share non-static members. Every object has its own copy.
  • (C) Objects of a class do not share codes of non-static methods, they have their own copy.
  • (D) None 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