Exercise: References

Questions for: References

Which of the following statement is correct about the program given below?
#include<iostream.h> 
class ExamAdept
{
    int x, y; 
    public:
    ExamAdept(int &xx, int &yy)
    {
        x = xx;
        y = yy;
        Display();
    }
    void Display()
    {
        cout<< x << " " << y;
    }
};
int main()
{
    int x1 = 10; 
    int &p = x1;
    int y1 = 20; 
    int &q = y1; 
    ExamAdept objBix(p, q); 
    return 0; 
}
A:
It will result in a compile time error.
B:
The program will print the output 10 20.
C:
The program will print two garbage values.
D:
The program will print the address of variable x1 and y1.
Answer: B
No answer description is available. Let's discuss.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
class ExamAdept
{
    int x, y; 
    public:
    void SetValue(int &xx, int &yy)
    {
        x =  xx ++;
        y =  yy; 
        Display();
    }
    void Display()
    {
        cout<< x << " " << y;
    }
};
int main()
{
    int x = 10;
    int &y = x;
    ExamAdept objBix;
    objBix.SetValue(x , y);
    return 0; 
}
A:
The program will print the output 10 10.
B:
The program will print the output 10 11.
C:
The program will print the output 11 11.
D:
The program will print the output 11 10.
Answer: B
No answer description is available. Let's discuss.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
class ExamAdept
{
    int x, y; 
    public:
    void SetValue(int &a, int &b)
    {
        a = 100;
        x = a;
        y = b;
        Display();
    }
    void Display()
    {
        cout<< x << " " << y; 
    }
};
int main()
{
    int x = 10;
    ExamAdept objBix;
    objBix.SetValue(x, x);
    return 0;
}
A:
The program will print the output 100 10.
B:
The program will print the output 100 100.
C:
The program will print the output 100 garbage.
D:
The program will print two garbage values.
Answer: B
No answer description is available. Let's discuss.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
class ExamAdept
{
    int x, y; 
    public:
    void SetValue(int &xx, int &yy)
    {
        x =  xx++;
        y =  yy; 
        cout<< xx << " " << yy;
    }
};
int main()
{
    int x = 10;
    int &y = x;
    ExamAdept objBix;
    objBix.SetValue(x , y);
    return 0; 
}
A:
The program will print the output 10 10.
B:
The program will print the output 10 11.
C:
The program will print the output 11 10.
D:
The program will print the output 11 11.
Answer: D
No answer description is available. Let's discuss.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
class Bix
{
    int x, y; 
    public:
    Bix(int x, int y)
    {
        this->x = x;
        this->y = y;
    }
    void Display()
    {
        cout<< x << " " << y;
    }
};
int main()
{
    int x = 50;
    int &y = x ;
    Bix b(y, x);
    return 0; 
}
A:
The program will print the output 50 50.
B:
The program will print the two garbage values.
C:
It will result in a compile time error.
D:
The program will print nothing.
Answer: D
No answer description is available. Let's discuss.
Ad Slot (Above Pagination)
Quiz