1. Which value we cannot assign to reference?
a) integer
b) floating
c) unsigned
d) null
2. Identify the incorrect statement
a) reference is the alternate name of the object
b) A reference value once defined can be reassigned
c) A reference value once defined cannot be reassigned
d) none of the mentioned
3. Which refrence modifier is used to define reference variable?
a) &
b) $
c) #
d) none of the mentioned
4. What is the output of this program?
a) In swap 105 In main 105
b) In swap 105 In main 510
c) In swap 510 In main 105
d) none of the mentioned
5. What does a reference provide?
a) Alternate name for the class
b) Alternate name for the variable
c) Alternate name for the pointer
d) none of the mentioned
6. What is the output of this program?
a) 9
b) 10
c) error
d) 11
7. What is the output of this program?
a) Hello world
b) Hello
c) world
d) compile time error
8. Identify the correct sentence regarding inequality between reference and pointer.
a) we can not create the array of reference.
b) we can create the Array of reference.
c) we can use reference to reference.
d) none of the mentioned
a) integer
b) floating
c) unsigned
d) null
Answer:d
2. Identify the incorrect statement
a) reference is the alternate name of the object
b) A reference value once defined can be reassigned
c) A reference value once defined cannot be reassigned
d) none of the mentioned
Answer:c
3. Which refrence modifier is used to define reference variable?
a) &
b) $
c) #
d) none of the mentioned
Answer:a
4. What is the output of this program?
#include <iostream>
using namespace std;
void swap(int &a, int &b);
int main()
{
int a = 5, b = 10;
swap(a, b);
cout << "In main " << a << b;
return 0;
}
void swap(int &a, int &b)
{
int temp;
temp = a;
a = b;
b = temp;
cout << "In swap " << a << b;
}
b) In swap 105 In main 510
c) In swap 510 In main 105
d) none of the mentioned
Answer:a
5. What does a reference provide?
a) Alternate name for the class
b) Alternate name for the variable
c) Alternate name for the pointer
d) none of the mentioned
Answer:b
6. What is the output of this program?
#include <iostream>
using namespace std;
int main()
{
int a = 9;
int & aref = a;
a++;
cout << "The value of a is " << aref;
return 0;
}
b) 10
c) error
d) 11
Answer:b
7. What is the output of this program?
#include <iostream>
using namespace std;
void print (char * a)
{
cout << a << endl;
}
int main ()
{
const char * a = "Hello world";
print(const_cast<char *> (a) );
return 0;
}
b) Hello
c) world
d) compile time error
Answer:a
8. Identify the correct sentence regarding inequality between reference and pointer.
a) we can not create the array of reference.
b) we can create the Array of reference.
c) we can use reference to reference.
d) none of the mentioned
Answer:a