Overloaded Function Names(C++ Programming ) Questions and Answers
Question 1.
What are the advantages of passing arguments by reference?
Changes to parameter values within the function also affect the original arguments.
There is need to copy parameter values (i.e. less memory used)
There is no need to call constructors for parameters (i.e. faster)
All of the mentioned
Explanation:-
Answer: Option D. -> All of the mentioned
None.
Question 2.
When our function doesn't need to return anything means what will we use/send as
parameter in function?
void
blank space
both a & b
none of the mentioned
Explanation:-
Answer: Option B. -> blank space
None.
Question 3.
What will happen while using pass by reference
The values of those variables are passed to the function so that it can manipulate them
The location of variable in memory is passed to the function so that it can use the same memory area for its processing
The function declaration should contain ampersand (& in its type declaration)
All of the mentioned
Explanation:-
Answer: Option B. -> The location of variable in memory is passed to the function so that it can use the same memory area for its processing
In pass by reference, we can use the function to access the variable and it can modify it.
Therefore we are using pass by reference.
Question 4.
Overloaded functions are
Very long functions that can hardly run
One function containing another one or more functions inside it.
Two or more functions with the same name but different number of parameters or type.
none of the mentioned
Explanation:-
Answer: Option C. -> Two or more functions with the same name but different number of parameters or type.
None.
Question 5.
What is the output of the following program?
1. #include 2. using namespace std; 3. int operate (int a, int b) 4. { 5. return (a * b); 6. } 7. float operate (float a, float b) 8. { 9. return (a / b); 10. } 11. int main() 12. { 13. int x = 5, y = 2; 14. float n = 5.0, m = 2.0; 15. cout
10.0 5.0
5.0 2.5
10.0 5
10 2.5
Explanation:-
Answer: Option D. -> 10 2.5
In this program, we are divide and multiply the values. Output: $ g++ over3.cpp $ a.out 10 2.5
Question 6.
What is the output of this program?
1. #include 2. using namespace std; 3. int Add(int X, int Y, int Z) 4. { 5. return X + Y; 6. } 7. double Add(double X, double Y, double Z) 8. { 9. return X + Y; 10. } 11. int main() 12. { 13. cout
11 12.1
12.1 11
11 12
compile time error
Explanation:-
Answer: Option D. -> compile time error
None.
Question 7.
Which of the following permits function overloading on c++?
type
number of arguments
both of the mentioned
none of the mentioned
Explanation:-
Answer: Option C. -> both of the mentioned
None.
Question 8.
In which of the following we cannot overload the function?
return function
caller
called function
none of the mentioned
Explanation:-
Answer: Option A. -> return function
While overloading the return function, it will rise a error, So we can’t overload the return function.
Question 9.
Function overloading is also similar to which of the following?
operator overloading
constructor overloading
destructor overloading
none of the mentioned
Explanation:-
Answer: Option B. -> constructor overloading
In constructor overloading, we will be using the same options availed in function overloading.