LakshyaEducation.in

VEDIC MATHS Video Series
  • Home
  • Video Series
    • Vedic Maths Videos
    • Quantitative Aptitude Videos
    • Class 8 Maths Videos
    • Class 9 Maths Videos
    • Class 10 Maths Videos
  • Quiz & Solutions
  • Blog
  • Store
  • Login
  • Contact Us
  • Home
  • Topic
  • C++ Programming
  • Operator Functions

C++ Programming

OPERATOR FUNCTIONS MCQs

Total Questions : 9

Question 1.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
ostream & operator
  1.    5
  2.    6
  3.    error
  4.    runtime error
 Discuss Question
Answer is Option C. -> error

In this program, there will arise an ambiguous overload for 5.

Question 2.

Operator overloading is


  1.    making c++ operator works with objects
  2.    giving new meaning to existing operator
  3.    making new operator
  4.    both a & b
 Discuss Question
Answer is Option D. -> both a & b

Operator overloading is the way adding operation to the existing operators.

Question 3.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
class myclass
4.
{
5.
public:
6.
int i;
7.
myclass *operator->()
8.
{return this;}
9.
};
10.
int main()
11.
{
12.
myclass ob;
13.
ob->i = 10;
14.
cout
  1.    10 10
  2.    11 11
  3.    error
  4.    runtime error
 Discuss Question
Answer is Option A. -> 10 10

In this program, -> operator is used to describe the member of the class and so we are getting this output.
Output:
$ g++ char4.cpp
$ a.out
10 10

Question 4.

Which of the following statements is NOT valid about operator overloading?


  1.    Only existing operators can be overloaded.
  2.    Overloaded operator must have at least one operand of its class type.
  3.    The overloaded operators follow the syntax rules of the original operator.
  4.    None of the mentioned
 Discuss Question
Answer is Option D. -> None of the mentioned

None.

Question 5.





1.
#include
2.
using namespace std;
3.
class Integer
4.
{
5.
int i;
.
public:
7.
Integer(int ii) : i(ii) {}
8.
const Integer
9.
operator+(const Integer& rv) const
10.
{
11.
cout
  1.    10 10
  2.    11 11
  3.    error
  4.    runtime error
 Discuss Question
Answer is Option A. -> 10 10

Answer: (a)
Explanation:We are using two operator functions and executing them and result is printed according to the order.
Output:
$ g++ oper2.cpp
$ a.out
operator+
operator+=

Question 6.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
class sample
4.
{
5.
public:
6.
int x, y;
7.
sample() {};
8.
sample(int, int);
9.
sample operator + (sample);
10.
};
11.
sample::sample (int a, int b)
12.
{
13.
x = a;
14.
y = b;
15.
}
16.
sample sample::operator+ (sample param)
17.
{
18.
sample temp;
19.
temp.x = x + param.x;
20.
temp.y = y + param.y;
21.
return (temp);
22.
}
23.
int main ()
24.
{
25.
sample a (4,1);
26.
sample b (3,2);
27.
sample c;
28.
c = a + b;
29.
cout
  1.    5, 5
  2.    7, 3
  3.    3, 7
  4.    None of the mentioned
 Discuss Question
Answer is Option B. -> 7, 3

In this program, we are adding the first number of a with first number of b by using opertor

function and also we are adding second number by this method also.
Output:
$ g++ oper.cpp
$ a.out
7, 3

Question 7.

How to declare operator function?


  1.    operator operator sign
  2.    operator
  3.    operator sign
  4.    None of the mentioned
 Discuss Question
Answer is Option A. -> operator operator sign

We have to declare the operator function by using operator, operator sign. Example "operator +"

where operator is a keyword and + is the symbol need to be overloaded.

Question 8.

Which of the following operators can't be overloaded?



  1.    ::
  2.    +
  3.    -
  4.    []
 Discuss Question
Answer is Option A. -> ::

None.

Question 9.

Pick the other name of operator function.


  1.    function overloading
  2.    operator overloading
  3.    member overloading
  4.    None of the mentioned
 Discuss Question
Answer is Option B. -> operator overloading

None.

  • Share on Facebook!
  • Share on Pinterest!

Sub Topics

  • Abstract Classes
  • Access Control
  • Argument Passing
  • Arrays
  • Booleans
  • C++ Concepts
  • Catching Exceptions
  • Character Types
  • Class Hierarchies And Abstract Classes
  • Class Hierarchies Introduction
  • Classes
  • Comments And Indentation
  • Complex Number Type
  • Constants
  • Constructors And Destructors
  • Container Design
  • Conversion Operators
  • Declaration
  • Default Arguments
  • Dereferencing
  • Derivation And Templates
  • Derived Classes
  • Design Of Class Hierarchies
  • Enumerations
  • Error Handling
  • Error Handling Alternatives
  • Essential Operators
  • Exception Specifications
  • Exceptions
  • Exceptions And Efficiency
  • Exceptions That Are Not Errors
  • Floating Point Types
  • Free Store
  • Friends
  • Function Call
  • Function Declarations
  • Function Templates
  • Functions
  • Grouping Of Exceptions
  • Header Files Usage
  • Increment And Decrement
  • Integer Types
  • Large Objects
  • Linkage
  • Macros
  • Modularization And Interfaces
  • Multiple Inheritance
  • Namespaces
  • Objects
  • Objects And Classes
  • Oops Concepts
  • Operator Functions
  • Operators
  • Overloaded Function Names
  • Pointer To Function
  • Pointer To Void
  • Pointers
  • Pointers Into Arrays
  • Pointers To Members
  • References
  • Resource Management
  • Run Time Type Information
  • Sequence Adapters
  • Sequences
  • Simple String Template
  • Sizes
  • Specialization
  • Standard Exceptions
  • Standard Library Design
  • Statements
  • String Class
  • Structures
  • Subscripting
  • Template Arguments To Specify Policy Usage
  • Types
  • Uncaught Exceptions
  • Unspecified Number Of Arguments
  • User Defined Types
  • Value Return
  • Vector
  • Void

Recent Posts

  • Ssc Exam Guide Book
  • Vedic Maths Faq
  • Sail E0 Results 2022
  • Sail E0 Exam Results Cancelled - Exam Will Be Rescheduled
  • Quantitative Aptitude Faqs
  • Is Ssc Difficult Than Upsc?
  • Best Ssc Exam For Girls

Recent Questions

Q.   The Value Engineering Technique In Which Experts Of The Same....

Q.   If Transcription Should Not Be Carried Out Beyond The Insert....

Q.   Buffalo Is To Leather As Llama Is To....?

Q.   Choose The Correct Answer From The Given Options To Fill The....

Q.   The Arithmetic Mean (average) Of The First 10 Whole Numbers ....

Q.   Which Governor General Is Remembered For The Annulment Of Th....

Q.   When The Voltage Across A Capacitor Is Tripled, The Stored C....

Q.   My Mother Bakes Cakes.

Q.   Log Mean Temperature Difference In Case Of Counter Flow Comp....

Q.   Which Of The Following Is Not A Matter Of Local Government?

Q.   Which Drugs Can Easily Pass The Placental Barrier?

Q.   Which Of The Following Is Not A Benefit Of BLAST?

Q.   A Part Of John's Salary Was Cut By The Government. What....

Q.   The Swollen Part Of The Pistil Is Known As ________ .

Q.   By Definition, Make A Map Is To Select Certain Features As R....

Q.   Which Of The Following Is The Best Tube Material From Therma....

Q.   If You Are Going To Use A Combination Of Three Or More AND A....

Q.   (a) A Ball Is Dropped From A Height Of 30m. After Striking T....

Q.   What Is The Approx. Value Of W, If W=(1.5)11, Given Log2 = 0....

Q.   In The Following Questions, The Symbols $, ©, *, @ And # Ar....

Topics

Computer Aptitude
SAIL Junior Officer (E-0)
10th Grade
11th Grade
12th Grade
4th Grade
5th Grade
6th Grade
7th Grade
8th Grade
9th Grade
NCERT
Cat
Commerce
Computer Science
Engineering
English
General Knowledge
Ias
Management
Quantitative Aptitude
Reasoning Aptitude
General Studies (Finance And Economics)
Vedic Maths
Analytical Instrumentation
Biochemistry
Bioinformatics
Biology
Biotechnology
Bitsat
Business Statistics
C Programming
C++ Programming
Cell Biology
Chemistry
Cost Accounting
Drug And Pharmaceutical Biotechnology
Electrical Measurement And Instrumentation
Environment Management
Environmental Biotechnology
Enzyme Technology
Financial Management And Financial Markets
Gate
General Science
Geography
Heat Transfer
History And National Movements
Human Anatomy And Physiology
Human And Cultural Diversity
Human Resource Management
Indian Economy
Indian Geography
Indian History
Indian Polity
Instrumentation Transducers
International Relations
Life Sciences
Marketing And Marketing Management
Mass Transfer
Mechanics Of Materials
Microbiology
Neet
Professional Communication
Renewable Energy
Sociology
Surveying
Total Quality Management
Uidai Aadhaar Supervisor Certification
Virology
LakshyaEducation.in
Lakshya Education
Bhilai,Chattisgarh,India
Email: admin@lakshyaeducation.in Phone: 07893519977 (WhatsApp)

Quick Links

  • Vedic Maths
  • Quantitative Aptitude
  • Class – IX Maths
  • Class – X Maths
  • Blog

Our Services

  • About us
  • Privacy
  • TOS
  • Refund / Cancellation
  • Contact
  • Affiliate Program
  • Copyright © 2022 All Right Reserved | Lakshya Education     ( )
    Login / Register

    Your Account will be created automatically when you click the below Google or Facebook Login Button.
    •   Login With Facebook
    •  Login With Google
     Login With Email/Password