C++ Programming - C++ Functions Multiple Choice Questions and Answers

Related Topics:

C++ Programming : C++ Functions

C++ Functions Multiple Choice Questions with Answers and Explanations asked in Programmers Interviews in Various Companies.
1. The signature of a function is its ..... ?
[A] Function code
[B] Prototype
[C] Call
[D] Parameter list

Answer: B. Prototype

2. What is true about inline functions ?
[A] It's a compulsion on the compiler to make function inline
[B] It's a request to the compiler to make te function inline
[C] It's the indication to the compiler that the function is recursive
[D] It's the indication to the compiler that the function is member function

Answer: B. It's a request to the compiler to make te function inline

3. Which member function of class cannot modify its objects attributes ?
[A] friend functions
[B] Private member functions
[C] Constant member functions
[D] Static member functions

Answer: C. Constant member functions

4. Which of the following parameter passing mechanism is/are supported by C++ but not in C?
[A] Pass by value
[B] Pass by reference
[C] Pass by value result
[D] All of the above

Answer: B. Pass by reference

5. Which of the following type of function is an ideal candidate for being declared inline ?
[A] A function that is small and is not called frequently
[B] A function that is small and is called frequently
[C] A function that is not small and is not called frequently
[D] A function that is not small and is called frequently

Answer: B. A function that is small and is called frequently

6. One of the disadvantage of pass by reference is that the called function may inadvertently corrupt the called data.This is avoided by ?
[A] passing pointers
[B] declaring the formal parameters constant
[C] declaring the actual parameters constant
[D] all of above

Answer: B. declaring the formal parameters constant

7. The library function exit() causes an exit from ?
[A] The loop in which it occurs
[B] The block in which it occurs
[C] The function in which it occurs
[D] The program in which it occurs

Answer: D. The program in which it occurs

8. The getche() library function
[A] returns a character when any key is pressed
[B] returns a character when ENTER is pressed
[C] displays a character on the screen when any key is pressed
[D] does not display a character on the screen

Answer: A. returns a character when any key is pressed

9. When an argument is passed by reference
[A] a variable is created in function to hold the argument value
[B] the function cannot access the argument value
[C] a temporary variable is created in the calling program to hold arguments value
[D] None of these

Answer: A. a variable is created in function to hold the argument value

10. Overloaded function
[A] are a group of functions,with the same value
[B] all have the same number and types of arguments
[C] make life simpler for programmers
[D] may fail unexpectedly due to stress

Answer: C. make life simpler for programmers


Comments: (Your feedback is valuable to us)

Manoj Hargude 1 year ago Reply

In a C++ language program, will an inline function be compiled inline always?
(i) Yes, always
(ii) Only sometimes
(iii) No, never
(iv) None of the above
please give me answer


siddhant jain 2 years ago Reply

Good


;