Home / Engineering / CPP Programming MCQs / Page 1

CPP Programming MCQs | Page - 1

Dear candidates you will find MCQ questions of CPP Programming here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.

M

Mr. Dubey • 51.43K Points
Coach

Q. 1) 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
View Answer Discuss Share

M

Mr. Dubey • 51.43K Points
Coach

Q. 2) When a copy constructor may be called?

(A) When an object of the class is returned by value.
(B) When an object of the class is passed (to a function) by value as an argument.
(C) When an object is constructed based on another object of the same class
(D) All of the above
View Answer Discuss Share

M

Mr. Dubey • 51.43K Points
Coach

Q. 3) Constructors have _____ return type.

(A) void
(B) char
(C) int
(D) no
View Answer Discuss Share

M

Mr. Dubey • 51.43K Points
Coach

Q. 4) 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
View Answer Discuss Share

M

Mr. Dubey • 51.43K Points
Coach

Q. 5) 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
View Answer Discuss Share

M

Mr. Dubey • 51.43K Points
Coach

Q. 6) 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
View Answer Discuss Share

M

Mr. Dubey • 51.43K Points
Coach

Q. 7) #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
View Answer Discuss Share

M

Mr. Dubey • 51.43K Points
Coach

Q. 8) Which operator is having the highest precedence?

(A) postfix
(B) unary
(C) shift
(D) equality
View Answer Discuss Share

M

Mr. Dubey • 51.43K Points
Coach

Q. 9) 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
View Answer Discuss Share

M

Mr. Dubey • 51.43K Points
Coach

Q. 10) Which of the following functions must use reference?

(A) Assignment operator function
(B) Copy Constructor
(C) Destructor
(D) Parameterized constructor
View Answer Discuss Share