Test Series - cpp

Test Number 25/102

Q: What we can’t place followed by the non-default arguments?
A. trailing arguments
B. default arguments
C. both trailing & default arguments
D. leading arguments
Solution: To avoid the ambiguity in arguments.
eg. if func(int a=3, int b);
so if we call func(5), here will 5 will be value of a or b, because 5 is first parameter so a should be 5 but as only one argument is given b should be 5. So to remove such ambiguity default parameters are kept at the end or rightmost side.
Q: If we start our function call with default arguments means, what will be proceeding arguments?
A. user argument
B. empty arguments
C. default arguments
D. user & empty arguments
Solution: As a rule, the default argument must be followed by default arguments only.
Q: What is the default return type of a function?
A. int
B. void
C. float
D. char
Solution: void is the default return value of any function, to handle both empty and non-empty values.
Q: Which header file is used to pass unknown number of arguments to function?
A. stdlib.h
B. string.h
C. stdarg.h
D. stdio.h
Solution: Because the cstdarg defines this header file to process the unknown number of arguments.
Q: How can you access the arguments that are manipulated in the function?
A. va_list
B. arg_list
C. both va_list & arg_list
D. vg_list
Solution: va_list is provided by C++ to access manipulated arguments in function.
Q: What is the maximum number of arguments or parameters that can be present in one function call?
A. 64
B. 256
C. 255
D. 16
Solution: C++ allows maximum number of 256 arguments in a function call.
Q: What will initialize the list of arguments in stdarg.h header file?
A. va_list
B. va_start
C. va_arg
D. vg_arg
Solution: va_start initialises the the list of arguments in  header file.
Q: To which does the function pointer point to?
A. variable
B. constants
C. function
D. absolute variables
Solution: A function pointer points to a function.
Q: What will we not do with function pointers?
A. allocation of memory
B. deallocation of memory
C. both allocation & deallocation of memory
D. finds memory status
Solution: As it is used to execute a block of code, So we will not allocate or deallocate memory.
Q: What is the default calling convention for a compiler in c++?
A. __cdecl
B. __stdcall
C. __pascal
D. __fastcall
Solution: __cdecl is the default calling convention for a compiler in c++.

You Have Score    /10