References Questions
Practice References MCQs with answers and explanations. Page 1 of 3.
Category
C++ Programming
Topic
References
Page
1 / 3
Mode
Practice
Questions
Open any question to view the answer and explanation.
C++ return by reference: evaluate the two claims
We can return a global variable by reference. 2) We cannot return a local variable by reference.
Open
View answer
C++ references: evaluate the two claims
Once a variable and a reference are linked, they remain tied. 2) After declaring one reference to a variable, another reference to the same variable is not allowed.
Open
View answer
In C++ language fundamentals, a reference behaves most like which of the following?
Choose the closest conceptual analogy used in programming pedagogy to describe a reference (while remembering that a reference is an alias, not a separate object).
Open
View answer
In C++, which statement about references is correct?
Select the rule that always applies to reference initialization and binding.
Open
View answer
Accessing through a C++ reference: which statement is correct?
Choose how you read or write the referred value via a reference.
Open
View answer
Returning a reference from a function in C++: which reasons are valid?
The returned information is a large object, so returning a reference is more efficient than copying.
The function's type must be an R-value.
Open
View answer
C++ reference reseating: which statement is correct?
Choose the rule that governs whether a reference can later refer to another variable.
Open
View answer
References in declarations: which statements are correct?
An array of references is acceptable.
We can create a reference to a reference.
Open
View answer
Which statement about C++ references is correct?
Select the fact that accurately reflects how references behave in real code.
Open
View answer
Storage and placement: where is a C++ reference stored?
Choose the most appropriate statement from the given options.
Open
View answer
Which statement about C++ references is correct?
Pick the most accurate description from the options provided.
Open
View answer
C++ syntax check: a reference is declared using which symbol?
Select the correct token used in declarations.
Open
View answer
C++ references: evaluate two claims
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.
Choose the single best option.
Open
View answer
C++ references: evaluate two claims
A reference is not a constant pointer.
A reference is automatically dereferenced when used.
Choose the single best option.
Open
View answer
C++ references: which statement about arrays of references and reseating is correct?
Open
View answer
C++ references vs pointers: evaluate two claims
Pointer to a reference and reference to a pointer are both valid.
When we use a reference, we are referring to its referent (the underlying object).
Open
View answer
C++ references: evaluate two claims
Changing through a reference changes the referent (the bound object).
We can create an array of references.
Open
View answer
C++ (old iostream.h): trace the ternary, references, and side effects—what does this program output and why?
#include<iostream.h>
int CuriousTabFunction(int m)
{
m *= m;
return ((10) * (m /= m));
}
int main()
{
int c = 9, *d = &c, e;
int &z = e;
e = CuriousTabFunction(c-- % 3 ? ++*d : (*d *= *d));
z = z + e / 10;
cout << c << " " << e;
return 0;
}
Open
View answer
C++ references with enum-backed ints: after chained increments and assignments, what are p, q, and z?
#include <iostream.h>
enum xyz { a, b, c };
int main()
{
int x = a, y = b, z = c; // 0,1,2
int &p = x, &q = y, &r = z;
p = z;
p = ++q;
q = ++p;
z = ++q + p++;
cout << p << " " << q << " " << z;
return 0;
}
Open
View answer
C++ reference semantics (post-increment in stream): what exact output appears and why?
#include<iostream.h>
int main()
{
int x = 10;
int &y = x;
x++;
cout << x << " " << y++;
return 0;
}
Open
View answer
Practice smarter
Solve a few questions daily and revisit weak topics regularly to improve accuracy.