Interview Questions Answers.ORG
Interviewer And Interviewee Guide
C++ Pointers & FunctionsC++ Operator OverloadingC++ Exception HandlingC++ TemplateC++ Friend Interviews Quizzes

Accounting

AccountingAccounts PayableAuditJunior AccountantSenior Accountant

Analysis

Data AnalystFinancial AnalystGISGIS AnalysisStatistics

Arts

Art DirectorAstrologistInternational RelationshipSociologyVisual Arts

Banking

ICICI Bank LtdLoan OfficerRecovery OfficerTreasuryUnderwriter

Basic Common

BehavioralBusiness intelligenceFreshers GraduatePuzzlesTargeted Selection

Community

Cable OperatorFirefighter SpecialistFuneral DirectorSpeech PathologistTranslator

Engineering

Automobile EngineeringChemical EngineeringCivil EngineeringElectrical EngineeringMechanical Engineering

Multimedia

3D AnimationCoreldrawDesign EngineerGraphics DesignerInterior Design

9th Class

9th Class Biology9th Class Chemistry9th Class Computer Studies9th Class Pakistan StudiesEnglish Grammar Section 9th Class

Accounting

Accounting ManagementBank Probationary Officer (PO)Financial Accounting Exam MCQsManagerial Accounting Exam MCQs

Civil Engineering

Building ConstructionRailwaysRCC Structures DesignSoil Mechanics and Foundation EngineeringSurveying

Engineering

Electrical EngineeringElectronic DevicesElectronics EngineeringEngineering MechanicsSoftware Engineering

Information Technology (IT)

Basics of ComputerComputer KnowledgeComputer OrganizationFundamentals Of ComputerWireless Communication

Soft Skills Quizzes MCQs

Communication Skills Exam MCQsCorporate Communication Exam MCQsLeadership Skills Exam MCQsNegotiation Skills Exam MCQsTime Management Exam MCQs

C++ Interviews

C++ Access Control IQC++ COM ActiveX IQC++ Constructors IQC++ Containers IQC++ Exception Handling IQC++ Friend IQC++ Inheritance IQC++ Inline Function IQC++ New And Delete IQC++ Operator Overloading IQC++ Pointers & Functions IQC++ Programmer IQC++ References IQC++ Static Data IQC++ Syntax IQC++ Template IQC++ Type Checking IQC++ Virtual Functions IQ

Role-specific C++ Operator Overloading Interview Questions & Answers:

Download Interview PDF

1. Pick the other name of operator function.
a) function overloading
b) operator overloading
c) member overloading
d) None of the mentioned

b) operator overloading

2. How to declare operator function?
a) operator operator sign
b) operator
c) operator sign
d) None of the mentioned

a) operator operator sign

3. Which of the following statements is NOT valid about operator overloading?
a) Only existing operators can be overloaded.
b) Overloaded operator must have at least one operand of its class type.
c) The overloaded operators follow the syntax rules of the original operator.
d) None of the mentioned

d) None of the mentioned

4. Operator overloading is:
a) making c++ operator works with objects
b) giving new meaning to existing operator
c) making new operator
d) both a & b

d) both a & b

5. The output of this program?

#include <iostream>
using namespace std;
ostream & operator<<(ostream & i, int n)
{
return i;
}
int main()
{
cout << 5 << endl;
cin.get();
return 0;
}
a) 5
b) 6
c) error
d) runtime error

c) error

6. Output of this program?

#include <iostream>
using namespace std;
class myclass
{
public:
int i;
myclass *operator->()
{return this;}
};
int main()
{
myclass ob;
ob->i = 10;
cout << ob.i << " " << ob->i;
return 0;
}
a) 10 10
b) 11 11
c) error
d) runtime error

a) 10 10

7. Output of this program?

#include <iostream>
using namespace std;
class Integer
{
int i;
public:
Integer(int ii) : i(ii) {}
const Integer
operator+(const Integer& rv) const
{
cout << "operator+" << endl;
return Integer(i + rv.i);
}
Integer&
operator+=(const Integer& rv)
{
cout << "operator+=" << endl;
i += rv.i;
return *this;
}
};
int main()
{
int i = 1, j = 2, k = 3;
k += i + j;
Integer ii(1), jj(2), kk(3);
kk += ii + jj;
}
a) operator+
operator+=
b) operator+=
operator+
c) operator+
operator+
d) None of the mentioned

a) operator+
operator+=

8. Output of Program?

#include <iostream>
using namespace std;
class sample
{
public:
int x, y;
sample() {};
sample(int, int);
sample operator + (sample);
};
sample::sample (int a, int b)
{
x = a;
y = b;
}
sample sample::operator+ (sample param)
{
sample temp;
temp.x = x + param.x;
temp.y = y + param.y;
return (temp);
}
int main ()
{
sample a (4,1);
sample b (3,2);
sample c;
c = a + b;
cout << c.x << "," << c.y;
return 0;
}
a) 5, 5
b) 7, 3
c) 3, 7
d) None of the mentioned

b) 7, 3

9. Which of the following operators can't be overloaded?
a) ::
b) +
c) -
d) []

a) ::

10. Pick out the correct syntax of operator conversion.
a) operator float()const
b) operator float()
c) operator const
d) None of the mentioned

a) operator float()const

Download Interview PDF



SHARE




FORUM
PRIVACY
TERMS & CONDITIONS
FEED BACK

Submit Your Feedback:


×

Thank You For Your Feedback!

Your message has been sent successfully.

Disclaimer
Interview Questions Answers .ORG is responsive and optimized web portal for individuals to get preparation for their job interviews, learning and training. Content at Interview Questions Answers .ORG might be simplified to improve our users experience. We constantly review our content to avoid errors and copyright violations, but we cannot warrant full correctness of all the content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2007-2023 by Interview Questions Answers .ORG All Rights Reserved.

Interview Questions Answers .ORG
Face Book Twitter Linkedin