a. ==
b. —
c. /
d. &
The correct option is (b)
Explanation:
&, == and / requires two operands whereas — requires only one operand, in general, it decreases the value of operand by 1
a. &&
b. |||
c. ===
d. ??
The correct option is (d)
Explanation:
?: is known ternary operator because it separates three expressions. exp1 ? exp2 : exp3.
a. :: (Scope Resolution Operator)
b. .* (Pointer-to-member Operator )
c. .* (Pointer-to-member Operator )
d. All of the above
The correct option is (d)
Explanation:
All of the above operator cannot be overloaded.
a. 0
b. 1
c. 2
d. 3
The correct option is (a)
Explanation:
While overloading binary operators using member function, it requires 0 argument.
a. 1.
b. 2.
c. 3
d. 4
The correct option is (c)
Explanation:
There are Three different approaches used for operator overloading:
i. Overloading unary operator.
ii. Overloading binary operator.
iii. Overloading binary operator using a friend function.
a. –.
b. +.
c. %
d. ?:
The correct option is (d)
Explanation:
?:, :: and . cannot be overloaded +, -, % can be overloaded.
a. ()
b. ->
c. |=
d. []
The correct option is (c)
Explanation:
When an operator overloaded function is declared as friend function then [], () and -> cannot be overloaded.
a. 0
b. 1
c. 2
d. 3
The correct option is (b)
Explanation:
In the case of friend operator overloaded functions unary operator overloaded function should take maximum one object argument only.
a. Segmentation fault as two string cannot be added in C++.
b. The statements runs perfectly.
c. Error because s1+s2 will result into string and no string has substr() function.
d. Run-time error.
The correct option is (b)
Explanation:
string is class in C++, therefore when we do (s1+s2) a temporary object is created which stores the result of s1+s2 and then that object calls the function substr() and as that is an object of string class hence substr is a callable function for that temporary string object.
a. Segmentation fault.
b. No output
c. Error as a private member a is referenced outside the class.
d. Program compiles successfully but gives run-time error.
The correct option is (b)
Explanation:
As every static member must be initialized and we have initialized variable ‘x’ so no run time error. Also as variable ‘x’ is a static member and is referenced using the class for initialization therefore no compiler error.