Operator overloading Solved MCQ’s (OOP)

15 min
Score: 0
Attempted: 0/15
Subscribe
1. What is the output of the following code in C++? (Operator Overloading)
class A{int x; public: A(int a){x=a;} A operator+(A o){return A(x+o.x);} void show(){cout<int main(){A a1(10),a2(20),a3=a1+a2; a3.show();}




2. Which operator can be overloaded in C++?



3. What is the output of the following code?
class A{int x; public: A(int a){x=a;} void operator++(){++x;} void show(){cout<int main(){A obj(5); ++obj; obj.show();}




4. What is the output of the following code?
class A{int x; public: A(int a){x=a;} A operator-(A o){return A(x-o.x);} void show(){cout<int main(){A a1(10),a2(3); A a3=a1-a2; a3.show();}




5. Which operator cannot be overloaded in C++?



6. What is the output of the following code?
class A{int x; public: A(int a){x=a;} friend A operator*(A a,A b){return A(a.xb.x);} void show(){cout<int main(){A a1(2),a2(4); A a3=a1a2; a3.show();}




7. Operator overloading is an example of which concept?



8. What is the output of the following code?
class A{int x; public: A(int a){x=a;} bool operator>(A o){return x>o.x;}};
int main(){A a1(5),a2(3); cout<<(a1>a2);}




9. Which function is used to overload an operator?



10. What is the output of the following code?
class A{int x; public: A(int a){x=a;} void operator–(){x–;} void show(){cout<int main(){A obj(8); –obj; obj.show();}




11. Which operator is commonly overloaded using a friend function?



12. What is the output of the following code?
class A{int x; public: A(int a){x=a;} A operator/(A o){return A(x/o.x);} void show(){cout<int main(){A a1(20),a2(5); A a3=a1/a2; a3.show();}




13. Operator overloading allows operators to:



14. What is the output of the following code?
class A{int x; public: A(int a){x=a;} bool operator==(A o){return x==o.x;}};
int main(){A a1(5),a2(5); cout<<(a1==a2);}




15. Which of the following statements about operator overloading is correct?



OOP MCQs 

Programming C Plus Plus MCQs Homepage

shamil memory table

Computer Science Repeated MCQs Book Download

Leave a Reply

Contents Copyrights Reserved By T4Tutorials