C/C /C Programming - References Sample Test,Sample questions

Question:
 
Which of the following statement is correct about the program given below?

#include<iostream.h> 
class IndiaBix
{
    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;
    IndiaBix objBix;
    objBix.SetValue(x, x);
    return 0;
}
A. 
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.
E. It will result in a compile time error.
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.

1.The program will print the output 100 10.

2.The program will print the output 100 100.

3.The program will print the output 100 garbage.

4.The program will print two garbage values.

Posted Date:-2021-02-24 02:30:50


Question:
  
What will be the output of the following program?

#include<iostream.h> 
class BixTest
{
    public:
    BixTest(int &x, int &y)
    {
        x++;
        y++;
    } 
};
int main()
{
    int a = 10, b = 20;
    BixTest objBT(a, b); 
    cout<< a << " " << b; 
    return 0; 
}

1.10 20

2.1121

3. Garbage Garbage

4. It will result in a compile time error.

Posted Date:-2021-02-24 02:30:50


Question:
.  
Which of the following statement is correct about the program given below?

#include<iostream.h> 
class IndiaBix
{
    int x, y; 
    public:
    IndiaBix(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; 
    IndiaBix objBix(p, q); 
    return 0; 

1.It will result in a compile time error. C. The program will print two garbage values. D.

2.It will result in a compile time error.

3. The program will print two garbage values

4.The program will print the address of variable x1 and y1.

Posted Date:-2021-02-24 02:30:50


Question:
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; 
}

1.2 3 6

2.4 4 7

3.4 5 8

4. 3 4 6

Posted Date:-2021-02-24 02:30:50


Question:
What will be the output of the program given below?

#include<iostream.h> 
class BixBase
{
    int x;
    public:
    BixBase(int xx = 0)
    {
        x = xx; 
    }
    void Display()
    {
        cout<< x ;
    }
};
class BixDerived : public BixBase
{
    int y; 
    public:
    BixDerived(int yy = 0)
    {
        y = yy;
    }
    void Display()
    {
        cout<< y ;
    }
};
int main()
{
    BixBase objBase(10); 
    BixBase &objRef = objBase;

    BixDerived objDev(20); 
    objRef = objDev;

    objDev.Display(); 
    return 0; 
}

1.0

2.10

3.20

4.Garbage-value

Posted Date:-2021-02-24 02:30:50


Question:
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; 
}

1.The program will print the output 50 50.

2.The program will print the two garbage values.

3.It will result in a compile time error.

4. The program will print nothing.

Posted Date:-2021-02-24 02:30:50


Question:
Which of the following statement is correct about the program given below?

#include<iostream.h> 
class IndiaBix
{
    int a, b, c; 
    public:
    void SetValue(int x, int y ,int z)
    {
        a = x;
        b = y;
        c = z;
    } 
    void Display()
    {
        cout<< a << " " << b << " " << c;
    } 
}; 
int main()
{
    IndiaBix objBix;
    int x  = 2;
    int &y = x;
    y = 5;
    objBix.SetValue(x, ++y, x + y);
    objBix.Display();
    return 0; 
}

1.The program will print the output 5 6 10.

2.The program will print the output 6 6 10.

3.The program will print the output 6 6 12.

4.It will result in a compile time error.

Posted Date:-2021-02-24 02:30:50


Question:
Which of the following statement is correct about the program given below?

#include<iostream.h> 
class IndiaBix
{
    int x, y; 
    public:
    IndiaBix(int xx = 0, int yy = 0)
    {
        x = xx; 
        y = yy;
    }
    void Display()
    {
        cout<< x << " " << y;
    }
    IndiaBix operator +(IndiaBix z)
    {
        IndiaBix objTemp;
        objTemp.x = x + z.x;
        objTemp.y = y + z.y;
        return objTemp; 
    }
};
int main()
{
    IndiaBix objBix1(90, 80); 
    IndiaBix objBix2(10, 20); 
    IndiaBix objSum; 
    IndiaBix &objRef = objSum; 
    objRef = objBix1 + objBix2; 
    objRef.Display(); 
    return 0; 
}

1. It will result in a runtime error.

2. It will result in a compile time error.

3.The program will print the output 9 4.

4.The program will print the output 100 100.

Posted Date:-2021-02-24 02:30:50


Question:
Which of the following statement is correct about the program given below?

#include<iostream.h> 
class IndiaBix
{
    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;
    IndiaBix objBix;
    objBix.SetValue(x , y);
    return 0; 
}.

1. The program will print the output 10 10.

2.The program will print the output 10 11.

3.The program will print the output 11 11.

4.The program will print the output 11 10.

Posted Date:-2021-02-24 02:30:50


Question:
Which of the following statement is correct about the program given below?

#include<iostream.h> 
class IndiaBix
{
    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;
    IndiaBix objBix;
    objBix.SetValue(x , y);
    return 0; 
}

1.The program will print the output 10 10.

2.The program will print the output 10 11.

3.The program will print the output 11 10.

4. The program will print the output 11 11.

Posted Date:-2021-02-24 02:30:50


Question:
Which of the following statement is correct about the program given below?

#include<iostream.h> 
enum bix
{
    a=1, b, c
};
int main()
{
    int x = c;
    int &y = x;
    int &z = x;
    y = b;
    cout<< z--;
    return 0; 
}

1. It will result in a compile time error.

2.The program will print the output 1.

3.The program will print the output 2.

4.The program will print the output 3.

Posted Date:-2021-02-24 02:30:50


Question:
Which of the following statement is correct about the program given below?

#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 = ++x;
    q = ++y;
    r = ++c;
    cout<< p << q << r;
    return 0;
}

1.The program will print the output 1 2 3.

2.The program will print the output 2 3 4.

3.The program will print the output 0 1 2.

4. It will result in a compile time error.

Posted Date:-2021-02-24 02:30:50


Question:
Which of the following statement is correct about the program given below?

#include<iostream.h> 
int BixFunction(int m)
{
    m *= m;
    return((10)*(m /= m)); 
}
int main()
{
    int c = 9, *d = &c, e;
    int &z = e;
    e = BixFunction(c-- % 3 ? ++*d :(*d *= *d));
    z = z + e / 10;
    cout<< c << " " << e;
    return 0;
}

1.It will result in a compile time error.

2.The program will print the output 64 9.

3.The program will print the output 64 10.

4.The program will print the output 64 11.

Posted Date:-2021-02-24 02:30:50


Question:
Which of the following statement is correct about the program given below?

#include<iostream.h> 
int i, j; 
class IndiaBix
{
    public:
    IndiaBix(int x = 0, int y = 0)
    {
        i = x; 
        j = x; 
        Display();
    }
    void Display()
    {
        cout<< j <<" ";
    } 
}; 
int main()
{
    IndiaBix objBix(10, 20); 
    int &s = i; 
    int &z = j; 
    i++;
    cout<< s-- << " " << ++z; 
    return 0; 

1.The program will print the output 0 11 21.

2. The program will print the output 10 11 11.

3. The program will print the output 10 11 21.

4.The program will print the output 10 11 12.

Posted Date:-2021-02-24 02:30:50


Question:
Which of the following statement is correct about the program given below?

#include<iostream.h> 
int main()
{
    int arr[] = {1, 2 ,3, 4, 5}; 
    int &zarr = arr;
    for(int i = 0; i <= 4; i++)
    {
        arr[i] += arr[i];
    }
    for(i = 0; i <= 4; i++)
        cout<< zarr[i]; 
    return 0; 
}

1.The program will print the output 1 2 3 4 5.

2. The program will print the output 2 4 6 8 10.

3.The program will print the output 1 1 1 1 1.

4. It will result in a compile time error.

Posted Date:-2021-02-24 02:30:50


Question:
Which of the following statement is correct about the program given below?

#include<iostream.h> 
int main()
{
    int m = 2, n = 6;
    int &x = m++;
    int &y = n++;
    m = x++; 
    x = m++;
    n = y++;
    y = n++;
    cout<< m << " " << n; 
    return 0; 
}

1.The program will print output 3 7.

2.The program will print output 4 8.

3.The program will print output 5 9.

4. It will result in a compile time error.

Posted Date:-2021-02-24 02:30:50


Question:
Which of the following statement is correct about the program given below?

#include<iostream.h> 
int main()
{
    int m = 2, n = 6;
    int &x = m;
    int &y = n;
    m = x++; 
    x = m++;
    n = y++;
    y = n++;
    cout<< m << " " << n; 
    return 0; 
}

1.The program will print output 2 6.

2.The program will print output 3 7.

3.The program will print output 4 8.

4.The program will print output 5 9.

Posted Date:-2021-02-24 02:30:50


Question:
Which of the following statement is correct about the program given below?

#include<iostream.h> 
int main()
{
    int x = 0;
    int &y = x; y = 5; 
    while(x <= 5)
    {
        cout<< y++ << " ";
        x++;
    }
    cout<< x; 
    return 0; 
}

1.The program will print the output 5 6 7 8 9 10.

2.The program will print the output 5 6 7 8 9 10 7.

3.The program will print the output 5 7.

4.It will result in a compile time error.

Posted Date:-2021-02-24 02:30:50


Question:
Which of the following statement is correct about the program given below?

#include<iostream.h> 
int main()
{
    int x = 10, y = 20;
    int *ptr = &x;
    int &ref = y;

    *ptr++;
     ref++;    

    cout<< x << " " << y;
    return 0; 
}

1.The program will print the output 10 20.

2.The program will print the output 10 21.

3.The program will print the output 11 20.

4.The program will print the output 11 21.

Posted Date:-2021-02-24 02:30:50


Question:
Which of the following statement is correct about the program given below?

#include<iostream.h> 
int main()
{
    int x = 10;
    int &y = x;
    x = 25;
    y = 50;
    cout<< x << " " << --y;
    return 0; 
}

1.The program will print the output 25 49.

2. It will result in a compile time error.

3.The program will print the output 50 50.

4.The program will print the output 49 49

Posted Date:-2021-02-24 02:30:50


Question:
Which of the following statement is correct about the program given below?

#include<iostream.h> 
int main()
{
    int x = 10;
    int &y = x;
    x++;
    cout<< x << " " << y++;
    return 0; 
}

1.The program will print the output 11 12.

2.The program will print the output 12 11.

3.The program will print the output 12 13.

4.It will result in a compile time error

Posted Date:-2021-02-24 02:30:50


Question:
Which of the following statement is correct about the program given below?

#include<iostream.h> 
int main()
{
    int x = 80; 
    int &y = x;
    x++;
    cout << x << " " << --y;
    return 0;
}

1.The program will print the output 80 80.

2.The program will print the output 81 80.

3.The program will print the output 81 81.

4.. It will result in a compile time error.

Posted Date:-2021-02-24 02:30:50


Question:
Which of the following statement is correct about the program given below?

#include<iostream.h> 
int x, y; 
class BixTest
{
    public:
    BixTest(int xx = 0, int yy = 0)
    {
        x = xx;
        y = yy;
        Display(); 
    } 
    void Display()
    {
        cout<< x << " " << y << " ";
    }
};
int main()
{
    BixTest objBT(10, 20); 
    int &rx = x; 
    int &ry = y; 
    ry = x;
    rx = y;
    cout<< rx--; 
    return 0; 
}

1.The program will print the output 0 0 10.

2.The program will print the output 10 20 10.

3.The program will print the output 10 20 9.

4.It will result in a compile time error.

Posted Date:-2021-02-24 02:30:50


Question:
Which of the following statement is correct about the program given below?

#include<iostream.h> 
struct Bix
{
    short n;
};
int main()
{
    Bix b;
    Bix& rb = b;
    b.n = 5;
    cout << b.n << " " << rb.n << " ";
    rb.n = 8;
    cout << b.n << " " << rb.n;
    return 0; 
}

1.It will result in a compile time error.

2.The program will print the output 5 5 5 8.

3.The program will print the output 5 5 8 8.

4.The program will print the output 5 5 5 5.

Posted Date:-2021-02-24 02:30:50


Question:
Which of the following statement is correct about the program given below?  #include<iostream.h>  int main() {     int x = 80;      int y& = x;     x++;     cout << x << "" "" << --y;     return 0; }

1.The program will print the output 80 80.

2.The program will print the output 81 80.

3.The program will print the output 81 81.

4.It will result in a compile time error.

Posted Date:-2021-02-24 02:30:50


More MCQS

  1. C++ Programming MCQS Set-1
  2. C++ Multiple Choice Questions Set-1
  3. C++ Multiple Choice Questions Set-2
  4. C++ Programming MCQS Set-2
  5. C++ Programming MCQS Set-3
  6. C++ Programming MCQS Set-4
  7. C++ (CPP) MCQ Question with Answer
  8. Advanced c++ multiple choice question(MCQS)
  9. OOPS Quiz Questions and Answers(MCQS)
  10. C Programming - MCQ Questions Set 1
  11. C Programming - MCQ Questions Set 2
  12. C Programming - MCQ Questions Set 3
  13. C Programming - MCQ Questions Set 4
  14. C Programming - MCQ Questions Set 5
  15. C++ programming language MCQ Questions Set 1
  16. C++ programming language MCQ Questions Set 2
  17. C++ programming language MCQ Questions Set 3
  18. C++ programming language MCQ Questions Set 4
  19. C++ programming language MCQ Questions Set 5
  20. C++ Programming -Constructors and Destructors
  21. C++ Programming -OOPS Concepts
  22. C++ Programming - References
  23. C++ Programming - Functions
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!