logo

CuriousTab

CuriousTab

References problems


  • 1. 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;
    }

  • Options
  • A. The program will print the output 80 80.
  • B. The program will print the output 81 80.
  • C. The program will print the output 81 81.
  • D. It will result in a compile time error.
  • Discuss
  • 2. What will be the output of the program given below?
    #include<iostream.h> 
    class CuriousTabBase
    {
        int x;
        public:
        CuriousTabBase(int xx = 0)
        {
            x = xx; 
        }
        void Display()
        {
            cout<< x ;
        }
    };
    class CuriousTabDerived : public CuriousTabBase
    {
        int y; 
        public:
        CuriousTabDerived(int yy = 0)
        {
            y = yy;
        }
        void Display()
        {
            cout<< y ;
        }
    };
    int main()
    {
        CuriousTabBase objBase(10); 
        CuriousTabBase &objRef = objBase;
    
        CuriousTabDerived objDev(20); 
        objRef = objDev;
    
        objDev.Display(); 
        return 0; 
    }

  • Options
  • A. 0
  • B. 10
  • C. 20
  • D. Garbage-value
  • E. It will result in a compile-time/run-time error.
  • Discuss
  • 3. Which of the following statement is correct about the program given below?
    #include<iostream.h> 
    class CuriousTab
    {
        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;
        CuriousTab objCuriousTab;
        objCuriousTab.SetValue(x , y);
        return 0; 
    }

  • Options
  • 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.
  • E. It will result in a compile time error.
  • Discuss
  • 4. Which of the following statement is correct about the program given below?
    #include<iostream.h> 
    int x, y; 
    class CuriousTabTest
    {
        public:
        CuriousTabTest(int xx = 0, int yy = 0)
        {
            x = xx;
            y = yy;
            Display(); 
        } 
        void Display()
        {
            cout<< x << " " << y << " ";
        }
    };
    int main()
    {
        CuriousTabTest objBT(10, 20); 
        int &rx = x; 
        int &ry = y; 
        ry = x;
        rx = y;
        cout<< rx--; 
        return 0; 
    }

  • Options
  • A. The program will print the output 0 0 10.
  • B. The program will print the output 10 20 10.
  • C. The program will print the output 10 20 9.
  • D. It will result in a compile time error.
  • Discuss
  • 5. 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;
    }

  • Options
  • A. The program will print the output 1 2 3.
  • B. The program will print the output 2 3 4.
  • C. The program will print the output 0 1 2.
  • D. It will result in a compile time error.
  • Discuss
  • 6. Which of the following statement is correct about the program given below?
    #include<iostream.h> 
    struct Tab
    {
        short n;
    };
    int main()
    {
        Tab b;
        Tab& rb = b;
        b.n = 5;
        cout << b.n << " " << rb.n << " ";
        rb.n = 8;
        cout << b.n << " " << rb.n;
        return 0; 
    }

  • Options
  • A. It will result in a compile time error.
  • B. The program will print the output 5 5 5 8.
  • C. The program will print the output 5 5 8 8.
  • D. The program will print the output 5 5 5 5.
  • Discuss
  • 7. Which of the following statement is correct about the program given below?
    #include<iostream.h> 
    class CuriousTab
    {
        int x, y; 
        public:
        CuriousTab(int xx = 0, int yy = 0)
        {
            x = xx; 
            y = yy;
        }
        void Display()
        {
            cout<< x << " " << y;
        }
        CuriousTab operator +(CuriousTab z)
        {
            CuriousTab objTemp;
            objTemp.x = x + z.x;
            objTemp.y = y + z.y;
            return objTemp; 
        }
    };
    int main()
    {
        CuriousTab objCuriousTab1(90, 80); 
        CuriousTab objCuriousTab2(10, 20); 
        CuriousTab objSum; 
        CuriousTab &objRef = objSum; 
        objRef = objCuriousTab1 + objCuriousTab2; 
        objRef.Display(); 
        return 0; 
    }

  • Options
  • A. It will result in a runtime error.
  • B. It will result in a compile time error.
  • C. The program will print the output 9 4.
  • D. The program will print the output 100 100.
  • Discuss
  • 8. 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; 
    }

  • Options
  • A. The program will print output 2 6.
  • B. The program will print output 3 7.
  • C. The program will print output 4 8.
  • D. The program will print output 5 9.
  • E. The program will print output 6 10.
  • Discuss
  • 9. Which of the following statement is correct about the program given below?
    #include<iostream.h> 
    int i, j; 
    class CuriousTab
    {
        public:
        CuriousTab(int x = 0, int y = 0)
        {
            i = x; 
            j = x; 
            Display();
        }
        void Display()
        {
            cout<< j <<" ";
        } 
    }; 
    int main()
    {
        CuriousTab objCuriousTab(10, 20); 
        int &s = i; 
        int &z = j; 
        i++;
        cout<< s-- << " " << ++z; 
        return 0; 
    }

  • Options
  • A. The program will print the output 0 11 21.
  • B. The program will print the output 10 11 11.
  • C. The program will print the output 10 11 21.
  • D. The program will print the output 10 11 12.
  • E. It will result in a compile time error.
  • Discuss
  • 10. Which of the following statement is correct about the program given below?
    #include<iostream.h> 
    class CuriousTab
    {
        int x, y; 
        public:
        CuriousTab(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; 
        CuriousTab objCuriousTab(p, q); 
        return 0; 
    }

  • Options
  • 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.
  • Discuss

First 2 3 4 5