Test Series - oops

Test Number 51/78

Q: Why the left parameter is removed from parameter list?
A. Because it is of no use
B. Because it is never used in definitions
C. Because it becomes parameter pointed by *this
D. Because it can’t be referred by *this pointer
Solution: The left object is removed from being passed as a parameter, because it is implicitly passed. It is passed implicitly because it is considered the object with respect to which the overloading function is being called.
Q: Which object’s members can be called directly while overloading operator function is used (In function definition)?
A. Left operand members
B. Right operand members
C. All operand members
D. None of the members
Solution: This is because the left operand is passed implicitly. It is pointed by *this. This in turn means we can use the direct member names of the object because those are again converted to a syntax containing *this pointer implicitly.
Q: Which operator among the following can be overloading using only member function?
A. Assignment operator
B. Addition operator
C. Subtraction operator
D. Multiplication and division operator
Solution: Only the assignment operator among the options given must be overloaded using the member functions. The assignment operator can’t be overloaded using friend function. This is a restriction in the programming languages to make the programs more resistant towards errors.
Q: If left operand member is specified directly in the function definition, which is the correct implicit conversion of that syntax?
A. *this className
B. *this parameterObject
C. *this returnedObject
D. *this object
Solution: Since the left operands are passed implicitly, those object members can be accessed directly in the function definition. The compiler converts the syntax into the syntax that can be processed. The implicitly converted syntax contains *this pointer followed by the objectName that is left operand in the expression.
Q: Where in the parameter list is the implicit *this is added?
A. Right most parameter
B. Anywhere in parameter list
C. Left most parameter
D. Not added to parameter list
Solution: The left operand is passed implicitly by the compiler to the member function. But this is done, when the compiler adds the calling object as *this to the parameter list. It is always added as the left most parameter, i.e. the first parameter of the function.
Q: When the friend operator overloading is converted into member operator overloading _______________
A. Two parameters of friend function remains same parameters in member operator overloading
B. Two parameters of friend function becomes only one parameter of member function
C. Two parameters of friend function are removed while using member function
D. Two parameters of friend function are made 4 in member operator overloading
Solution: The friend function would accept two arguments if some binary operator is overloaded. When we try to convert that definition to member operator overloading then it becomes only one parameter. The reason behind is that the left operand is passed implicitly while using the member functions.
Q: Which operator among the following can be overloaded using both friend function and member function?
A. Assignment operator
B. Subscript
C. Member selection (arrow operator)
D. Modulus operator
Solution: Only the modulus operator among the given operators can be overloaded using either friend function or member function. Other operators must be overloaded using only the member functions.
Q: Which operator among the following must be overloaded using the friend function?
A. << operator only
B. >> operator only
C. Both << and >> operators
D. It’s not mandatory to use friend function in any case
Solution: In some cases it is mandatory to use the friend functions for overloading the operators. Here both the << and >> operators must be overloaded using friend function because the left operand is object of some other class and the right operand is usually of some different type.
Q: What does memory allocation for objects mean?
A. Actual creation and memory allocation for object members
B. Creation of member functions
C. Creation of data members for a class
D. Actual creation and data declaration for object members
Solution: The memory allocated for the object members indicates actual creation of the object members. This is known as memory allocation for object.
Q: Where is the memory allocated for the objects?
A. HDD
B. Cache
C. RAM
D. ROM
Solution: The memory for the objects or any other data is allocated in RAM initially. This is while we run a program all the memory allocation takes place in some RAM segments. Arrays in heap and local members in stack etc.

You Have Score    /10