Functions - C++ (MCQ) questions and answers

Here, you can read Functions multiple choice questions and answers with explanation.

1)   Can we alter/modify the values of data members of a class inside const member function?
- Published on 19 Oct 15

a. Yes
b. No
Answer  Explanation 

ANSWER: Yes

Explanation:
No explanation is available for this question!


2)   In a program, If there exists a function template with two parameters and normal function say void add(int , int), so add(3,4) will _____________________ .
- Published on 19 Jul 15

a. Invoke function template body as it is generic one
b. Invokes normal function as it exactly matches with its prototype
c. Not be called and Compiler issues warning
d. Not be called and Compiler issues ambiguity in calling add()
Answer  Explanation 

ANSWER: Invokes normal function as it exactly matches with its prototype

Explanation:
No explanation is available for this question!


3)   const member function does not allow to modify/alter value of any data member of the class.
- Published on 19 Jul 15

a. True
b. False
Answer  Explanation 

ANSWER: True

Explanation:
No explanation is available for this question!


4)   In any ways, Non-member function cannot have access to the private data of the class.
- Published on 19 Jul 15

a. True
b. False
Answer  Explanation 

ANSWER: False

Explanation:
No explanation is available for this question!


5)   A function can be declared as friend maximum only in two classes.
- Published on 17 Jul 15

a. True
b. False
Answer  Explanation 

ANSWER: False

Explanation:
No explanation is available for this question!


6)   Function overloading can also be achieved if two or more functions differ only in their return types.
- Published on 17 Jul 15

a. True
b. False
Answer  Explanation 

ANSWER: False

Explanation:
No explanation is available for this question!


7)   Assigning one or more function body to the same name is called ____________ .
- Published on 17 Jul 15

a. Function Overriding
b. Function Overloading
c. Both a and b
d. None of the above
Answer  Explanation 

ANSWER: Function Overloading

Explanation:
No explanation is available for this question!


8)   Predict the output:

float x= 3.1496;
cout << setpricision(2) << x;


- Published on 17 Jul 15

a. 3.14
b. 3.15
c. 3.00
d. None of these
Answer  Explanation 

ANSWER: None of these

Explanation:
No explanation is available for this question!


9)   Can member functions of one class be friend functions of another class?
- Published on 17 Jul 15

a. Yes
b. No
Answer  Explanation 

ANSWER: Yes

Explanation:
No explanation is available for this question!


10)   Default values for a function are specified when ____ .
- Published on 17 Jul 15

a. function is defined
b. function is declared
c. Both a and b
d. None of these
Answer  Explanation 

ANSWER: function is declared

Explanation:
No explanation is available for this question!


1 2