Operators in C++ MCQs Exercise I

Ques 1 Operators


Which of the following statements about operator overloading is true?

A Only binary operators can be overloaded.
B Overloaded operators cannot have default arguments.
C Overloaded operators must always be a member of a class.
D All operators can be overloaded.

Ques 2 Operators


What will be the output of the following code?

#include <iostream>
using namespace std;
int main() {
    int a = 5, b = 10, c = 0;
    c = a++ * --b;
    cout << a << " " << b << " " << c;
    return 0;
}

A 5 9 45
B 6 9 50
C 6 9 45
D 5 10 45

Ques 3 Operators


What is the correct output of the following code?


#include<iostream>
using namespace std;
int main ()
{
     int a=12, b=17, c;
     c = (a < b) ? a : b;
     cout << c;
     return 0;
}

A 17
B 12
C Runtime Error
D 29

Ques 4 Operators


What will be the output of the following code?

#include<iostream>
using namespace std;
int main() {
    int x = 10, y = 0, z;
    z = x / y;
    cout << z;
    return 0;
}

A Program will output 0.
B Program will output inf.
C Program will terminate with a runtime error.
D Undefined behavior.

Ques 5 Operators


Which of the following operators cannot be overloaded in C++?

A Ternary operator (?:)
B Scope resolution operator (::)
C Typeid operator (typeid)
D All of the above