VOOZH about

URL: https://www.geeksforgeeks.org/quizzes/references-gq/

⇱ Quiz about C++ References


Last Updated :
Discuss
Comments

Question 1

Which of the following functions must use reference.
  • Assignment operator function
  • Copy Constructor
  • Destructor
  • Parameterized constructor

Question 2

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;
} 
  • 3024
  • 6561
  • 55440
  • 161051

Question 3

Which of the following is FALSE about references in C++

  • References cannot be NULL

  • A reference must be initialized when declared

  • Once a reference is created, it cannot be later made to reference another object; it cannot be reset.

  • References cannot refer to constant value

Question 4

Predict the output of following C++ program.
  • Compiler Error: Function cannot be used as lvalue
  • 10
  • 30

Question 5

  • May cause runtime error
  • May cause compiler error
  • Always works fine.
  • 0

Question 6

Output of following C++ program?
  • x = 20
    ref = 30
    
  • x = 20
    ref = 20
    
  • x = 10
    ref = 30
    
  • x = 30
    ref = 30
    

There are 6 questions to complete.

Take a part in the ongoing discussion