- Home
- Placement
- Programming
- Operator Overloading
- Array
- Data Types
- Functions
- Loop & Control Statements
- Operators & Expressions
- Pointer
- Preprocessor
- Storage Classes
- Structure & Union
- Variables & Constants
- Classes and Objects
- Consructors and Destructors
- Exception handling
- File Handling
- Function Overloading
- Inheritance
- Operator Overloading
- Polymorphism
- Templates
C Language
C++ language
JAVA
-
-
( 1 ) Which of the following may be overloaded as an operator?
- 1) operator*()
- 2) *operator()
- 3) op*()
- 4) *op()
-
-
-
( 2 ) In case of operator overloading, operator function must be ______ .
1. Static member functions
2. Non- static member functions
3. Friend Functions - 1) Only 2
- 2) Only 1, 3
- 3) Only 2 , 3
- 4) All 1 , 2, 3
-
Show Answer Report Discussion in forumAnswer : 3) Only 2 , 3
Solution :
discussion
Answer : 3) Only 2 , 3
-
-
-
( 3 ) To overload an operator__________ keyword must be used along with the operator to be overloaded.
- 1) Over
- 2) Overload
- 3) Void
- 4) Operator
-
Show Answer Report Discussion in forumAnswer : 4) Operator
Solution :
discussion
Answer : 4) Operator
-
-
-
( 4 ) Which of the following can be overloaded?
- 1) Object
- 2) Functions
- 3) Operators
- 4) Both 2 & 3
-
Show Answer Report Discussion in forumAnswer : 4) Both 2 & 3
Solution :
discussion
Answer : 4) Both 2 & 3
-
-
-
( 5 ) The order in which operands are evaluated in an expression is predictable if the operator is;
- 1) *
- 2) +
- 3) %
- 4) &&
-
-
-
( 6 ) Which of the following operators can be overloaded?
- 1) . (dot or member access operator)
- 2) & ( address-of operator)
- 3) size of operator
- 4) ?: (conditional opeator)
-
Show Answer Report Discussion in forumAnswer : 2) & ( address-of operator)
Solution :
discussion
Answer : 2) & ( address-of operator)
-
-
-
( 7 ) Overloading a postfix increment operator by means of a member function takes
- 1) no argument
- 2) one argument
- 3) two arguments
- 4) three arguments
-
Show Answer Report Discussion in forumAnswer : 1) no argument
Solution :
discussion
Answer : 1) no argument
-
-
-
( 8 ) When overloading unary operators using Friend function,it requires_____ argument/s.
- 1) Zero
- 2) One
- 3) Two
- 4) None of these
-
Show Answer Report Discussion in forumAnswer : 2) One
Solution : 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.
discussion
Answer : 2) One
-
-
-
( 9 ) How to declare operator function?
- 1) operator operator sign
- 2) operator
- 3) operator sign
- 4) None of these
-
Show Answer Report Discussion in forumAnswer : 1) operator operator sign
Solution :
discussion
Answer : 1) operator operator sign
-
-
-
( 10 ) Predict the output
#include
using namespace std;
class A
{
int i;
public:
A(int ii = 0) : i(ii) {}
void show()
{
cout << i << endl;
}
};
class B
{
int x;
public:
B(int xx) : x(xx) {}
operator A() const { return A(x);
}
};
void g(A a)
{
a.show();
}
int main()
{
B b(10);
g(b);
g(20);
return 0;
} - 1) Compiler Erro
- 2) 10 20
- 3) 20 20
- 4) 10 10
-