InterviewSolution
Saved Bookmarks
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
What is the return value of f(p, p) if the value of p is initialized to 5 before the call? Note that the first parameter is passed by reference, whereas the second parameter is passed by value.int f(int &x, int c) { c = c - 1; if (c == 0) return 1; x = x + 1; return f(x, c) * x;} (A) 3024(B) 6561(C) 55440(D) 161051 |
| Answer» None | |
| 2. |
Which of the following is FALSE about references in C++(A) References cannot be NULL(B) A reference must be initialized when declared(C) Once a reference is created, it cannot be later made to reference another object; it cannot be reset.(D) References cannot refer to constant value |
| Answer» None | |
| 3. |
Which of the following functions must use reference.(A) Assignment operator function(B) Copy Constructor(C) Destructor(D) Parameterized constructor |
| Answer» | |
| 4. |
Output of following C++ program?#include<iostream>using namespace std;int main(){int x = 10;int& ref = x;ref = 20;cout << "x = " << x << endl ;x = 30;cout << "ref = " << ref << endl;return 0;}(A)x = 20ref = 30(B)x = 20ref = 20(C)x = 10ref = 30(D)x = 30ref = 30 |
| Answer» | |
| 5. |
#include<iostream>using namespace std;int &fun(){int x = 10;return x;}int main(){fun() = 30;cout << fun();return 0;}(A) May cause runtime error(B) May cause compiler error(C) Always works fine.(D) 0 |
| Answer» | |