Test Series - cpp

Test Number 24/102

Q: Which of the following permits function overloading on c++?
A. type
B. number of arguments
C. type & number of arguments
D. number of objects
Solution: Both type and number of arguments permits function overloading in C++, like
int func(int);
float func(float, float)
Here both type and number of arguments are different.
Q: In which of the following we cannot overload the function?
A. return function
B. caller
C. called function
D. main function
Solution: While overloading the return function, it will rise a error, So we can’t overload the return function.
Q: Function overloading is also similar to which of the following?
A. operator overloading
B. constructor overloading
C. destructor overloading
D. function overloading
Solution: In constructor overloading, we will be using the same options availed in function overloading.
Q: Overloaded functions are ________________
A. Very long functions that can hardly run
B. One function containing another one or more functions inside it
C. Two or more functions with the same name but different number of parameters or type
D. Very long functions
Solution: This is the definition of function overloading i.e. function having same name but different number of parameters and types.
Q: What will happen while using pass by reference?
A. The values of those variables are passed to the function so that it can manipulate them
B. The location of variable in memory is passed to the function so that it can use the same memory area for its processing
C. The function declaration should contain ampersand (& in its type declaration)
D. The function declaration should contain $
Solution: 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.
Q: What should be passed in parameters when function does not require any parameters?
A. void
B. blank space
C. both void & blank space
D. tab space
Solution: When we does not want to pass any argument to a function then we leave the parameters blank i.e. func() – function without any parameter.
Q: What are the advantages of passing arguments by reference?
A. Changes to parameter values within the function also affect the original arguments
B. There is need to copy parameter values (i.e. less memory used)
C. There is no need to call constructors for parameters (i.e. faster)
D. All of the mentioned
Solution: All the above mentioned are advantages and properties of call by reference.
Q: If the user did not supply the value, what value will it take?
A. default value
B. rise an error
C. both default value & rise an error
D. error
Solution: If the user did not supply the value means, the compiler will take the given value in the argument list.
Q: Where can the default parameter be placed by the user?
A. leftmost
B. rightmost
C. both leftmost & rightmost
D. topmost
Solution: To avoid the ambiguity between the non-default parameters and default parameters.
Q: Which value will it take when both user and default values are given?
A. user value
B. default value
C. custom value
D. defined value
Solution: The default value will be used when the user value is not given, So in this case, the user value will be taken.
Q: 
A. 
B. 
C. 
D. 
Solution: 
Q: Which of the following permits function overloading on c++?
A. type
B. number of arguments
C. type & number of arguments
D. number of objects
Solution: Both type and number of arguments permits function overloading in C++, like
int func(int);
float func(float, float)
Here both type and number of arguments are different.
Q: In which of the following we cannot overload the function?
A. return function
B. caller
C. called function
D. main function
Solution: While overloading the return function, it will rise a error, So we can’t overload the return function.
Q: Function overloading is also similar to which of the following?
A. operator overloading
B. constructor overloading
C. destructor overloading
D. function overloading
Solution: In constructor overloading, we will be using the same options availed in function overloading.
Q: Overloaded functions are ________________
A. Very long functions that can hardly run
B. One function containing another one or more functions inside it
C. Two or more functions with the same name but different number of parameters or type
D. Very long functions
Solution: This is the definition of function overloading i.e. function having same name but different number of parameters and types.
Q: What will happen while using pass by reference?
A. The values of those variables are passed to the function so that it can manipulate them
B. The location of variable in memory is passed to the function so that it can use the same memory area for its processing
C. The function declaration should contain ampersand (& in its type declaration)
D. The function declaration should contain $
Solution: 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.
Q: What should be passed in parameters when function does not require any parameters?
A. void
B. blank space
C. both void & blank space
D. tab space
Solution: When we does not want to pass any argument to a function then we leave the parameters blank i.e. func() – function without any parameter.
Q: What are the advantages of passing arguments by reference?
A. Changes to parameter values within the function also affect the original arguments
B. There is need to copy parameter values (i.e. less memory used)
C. There is no need to call constructors for parameters (i.e. faster)
D. All of the mentioned
Solution: All the above mentioned are advantages and properties of call by reference.
Q: If the user did not supply the value, what value will it take?
A. default value
B. rise an error
C. both default value & rise an error
D. error
Solution: If the user did not supply the value means, the compiler will take the given value in the argument list.
Q: Where can the default parameter be placed by the user?
A. leftmost
B. rightmost
C. both leftmost & rightmost
D. topmost
Solution: To avoid the ambiguity between the non-default parameters and default parameters.
Q: Which value will it take when both user and default values are given?
A. user value
B. default value
C. custom value
D. defined value
Solution: The default value will be used when the user value is not given, So in this case, the user value will be taken.

You Have Score    /21