Top 80+ Solved Object Oriented Programming (OOP) MCQ Questions Answer
Q. 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
Q. Output of following program?#include<iostream> using namespace std; class Point {Point() { cout <<"Constructor called"; }};int main(){Point t1; return 0;}
a. compile time error
b. run time error
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
Q. #include<iostream> using namespace std;class X{public:int x;};int main(){X a = {10};X b = a;cout <<a.x <<" " <<b.x; return 0;}
a. compiler error
b. 10 followed by garbage value
c. 10 10
d. 10 0