Home - Cpp Programming - References

References Online Exam Quiz

Important questions about References. References MCQ questions with answers. References exam questions and answers for students and interviews.

3. Which of the following statements is correct? Once a reference variable has been defined to refer to a particular variable it can refer to any other variable. A reference is not a constant pointer.

Options

A : Only 1 is correct.

B : Only 2 is correct.

C : Both 1 and 2 are correct.

D : Both 1 and 2 are incorrect.

4. Which of the following statements is correct? A reference is not a constant pointer. A referenced is automatically de-referenced.

Options

A : Only 1 is correct.

B : Only 2 is correct.

C : Both 1 and 2 are correct.

D : Both 1 and 2 are incorrect.

6. Which of the following statements is correct? Pointer to a reference and reference to a pointer both are valid. When we use reference, we are actually referring to a referent.

Options

A : Only 1 is correct.

B : Only 2 is correct.

C : Both 1 and 2 are correct.

D : Both 1 and 2 are incorrect.

7. Which of the following statements is correct? Change a reference changes the referent. We can create an array of references.

Options

A : Only 1 is correct.

B : Only 2 is correct.

C : Both 1 and 2 are correct.

D : Both 1 and 2 are incorrect.

9. What will be the output of the following program? #include <iostream.h> enum xyz { a, b, c }; int main() { int x = a, y = b, z = c; int &p = x, &q = y, &r = z; p = z; p = ++q; q = ++p; z = ++q + p++; cout<< p << " " << q << " " << z; return 0; }

Options

A : 2 3 6

B : 4 4 7

C : 4 5 8

D : 3 4 6

2. What will be the output of the program given below? #include<iostream.h> class CuriousTabBase { int x; public: CuriousTabBase(int xx = 0) { x = xx; } void Display() { cout<< x ; } }; class CuriousTabDerived : public CuriousTabBase { int y; public: CuriousTabDerived(int yy = 0) { y = yy; } void Display() { cout<< y ; } }; int main() { CuriousTabBase objBase(10); CuriousTabBase &objRef = objBase; CuriousTabDerived objDev(20); objRef = objDev; objDev.Display(); return 0; }

Options

A : 0

B : 10

C : 20

D : Garbage-value

1. Which of the following statement is correct about the program given below? #include<iostream> enum curioustab { a=1, b, c }; int main() { int x = c; int &y = x; int &z = x; y = b; std::cout<< z--; return 0; }

Options

A : It will result in a compile time error.

B : The program will print the output 1.

C : The program will print the output 2.

D : The program will print the output 3.

8. What will be the output of the following program? #include<iostream.h> class CuriousTabTest { public: CuriousTabTest(int &x, int &y) { x++; y++; } }; int main() { int a = 10, b = 20; CuriousTabTest objBT(a, b); cout<< a << " " << b; return 0; }

Options

A : 10 20

B : 11 21

C : Garbage Garbage

D : It will result in a compile time error.

3. Which of the following statements is correct? A reference is not a constant pointer. A referenced is automatically de-referenced.

Options

A : Only 1 is correct.

B : Only 2 is correct.

C : Both 1 and 2 are correct.

D : Both 1 and 2 are incorrect.

1. Which of the following statements is correct? We can return a global variable by reference. We cannot return a local variable by reference.

Options

A : Only 1 is correct.

B : Only 2 is correct.

C : Both 1 and 2 are correct.

D : Both 1 and 2 are incorrect.

2. Which of the following statements is correct? Once the variable and the reference are linked they are tied together. Once the reference of a variable is declared another reference of that variable is not allowed.

Options

A : Only 1 is correct.

B : Only 2 is correct.

C : Both 1 and 2 are correct.

D : Both 1 and 2 are incorrect.

3. Reference is like a _____.

Options

A : Pointer

B : Structure

C : Macro

D : Enum

4. Which of the following statement is correct about the references?

Options

A : A reference must always be initialized within functions.

B : A reference must always be initialized outside all functions.

C : A reference must always be initialized.

D : Both A and C.

6. Functions can be declared to return a reference type. There are reasons to make such a declaration/Which of the following reasons are correct? The information being returned is a large enough object that returning a reference is more efficient than returning a copy. The type of the function must be a R-value.

Options

A : Only 1 is correct.

B : Only 2 is correct.

C : Both 1 and 2 are correct.

D : Both 1 and 2 are incorrect.

8. Which of the following statements is correct? An array of references is acceptable. We can also create a reference to a reference.

Options

A : Only 1 is correct.

B : Only 2 is correct.

C : Both 1 and 2 are correct.

D : Both 1 and 2 are incorrect.

Cpp Programming more Online Exam Quiz

Copyright © 2021
Exam-GK-MCQ-Questions.Com | Contact Us | Privacy Policy | Terms of Use | Sitemap | 0.020411968231201